contributte / forms-multiplier

:repeat: Form multiplier & replicator for Nette Framework

Home Page:https://contributte.org/packages/contributte/forms-multiplier.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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!

@MartkCz Aha, that's it, thanks!

For future reference:

$multiplier->addRemoveButton('Remove')
    ->addOnCreateCallback(function($button) {
        $button->getControlPrototype()
            ->setName('button')
            ->setType('submit')
            ->setText($button->getCaption());
    });