forms-multiplier icon indicating copy to clipboard operation
forms-multiplier copied to clipboard

Set/get container values on add/delete

Open Eleana92 opened this issue 5 months ago • 0 comments

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.

Eleana92 avatar Sep 13 '24 08:09 Eleana92