Access to SubmitButtons
ne0-cz opened this issue · comments
Hi,
I can't seem to be able to access neither CreateButton's or RemoveButton's SubmitButton. All my submit buttons are actually <button>
s instead of <input>
s which is easily done for Form submit by extending Nette\Application\UI\Form
:
public function addSubmit($name, $caption = NULL): SubmitButton
{
$button = parent::addSubmit($name, $caption);
$element = $button->getControlPrototype();
$element->setName('button');
$element->setType('submit');
$element->setText($caption);
return $button;
}
I'd love to do the same for the multiplier buttons. It is actually useful to use real <button>
s in some cases - I add icons to my icons via CSS this way (<input>
s don't do CSS ::before
/::after
pseudo-elements).
Thanks!
Hi, did you try
https://github.com/contributte/forms-multiplier/blob/master/src/Buttons/CreateButton.php#L35-L40 and https://github.com/contributte/forms-multiplier/blob/master/src/Buttons/RemoveButton.php#L28-L33 in https://github.com/contributte/forms-multiplier/blob/master/src/Multiplier.php#L169-L177 ?
@MartkCz Aha, that's it, thanks!
For future reference:
$multiplier->addRemoveButton('Remove')
->addOnCreateCallback(function($button) {
$button->getControlPrototype()
->setName('button')
->setType('submit')
->setText($button->getCaption());
});