forms-multiplier
forms-multiplier copied to clipboard
Set/get container values on add/delete
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.