Skip to content

Set/get container values on add/delete #113

@Eleana92

Description

@Eleana92

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Triage: Next

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions