Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set/get container values on add/delete #113

Open
Eleana92 opened this issue Sep 13, 2024 · 0 comments
Open

Set/get container values on add/delete #113

Eleana92 opened this issue Sep 13, 2024 · 0 comments
Labels

Comments

@Eleana92
Copy link

Eleana92 commented Sep 13, 2024

Hello,
I am using the callbacks for the create and remove buttons. I want to add a new container with specific values and be able to retrieve the values of the removed container or at least its index.

        $multiplier->addSelect('select_item');
        $multiplier->addCreateButton('Add')
            ->addOnCreateCallback(function (Contributte\FormMultiplier\Submitter $submitter) {
                $submitter->onClick[] = function () use ($submitter): void {
                    $itemId = $submitter->parent['select_item']->getRawValue();
                    if ($itemId) {
                        $item = $this->getItem($itemId);

                        // Set item values to new container

                    }
                    $this->redrawControl('formContainer');
                    $this->redrawControl('form');
                };
            });
        $multiplier->addRemoveButton('Remove')
            ->addOnCreateCallback(function (SubmitButton $submitter) {
                $submitter->onClick[] = function () use ($submitter) {

                    // Get index/values of removed container

                    $this->redrawControl('formContainer');
                    $this->redrawControl('form');
                };
            }); 

Can you please help me on that? Thank you in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants