Give the submit button of a form a value/name


Hi there,

a HTML can have a name attribute, which is passed when submitting a form, e.g.

has $_POST[‘myOwnSubmit’] set when clicking the button. Is there a simple way to achieve something similar in Agile UI buttons?

I am using a “hack” to make the Autocomplete autosubmittable, see It submits the form on change as a normal $autocomplete_field->on(‘change’, …) does not work.

Now I am using an AutoComplete somewhere else where the “real” form submit should do something quite different, so inside the submit function I need to determine whether the AutoComplete caused the submit or clicking the button. As the AutoComplete might pass an empty value, I need to determine if the button was clicked by passing some value with it.
Maybe some small change to onClick Eventhandler? $form->buttonSave->on(‘click’, $form->js()->form(‘submit’, ‘someExtraParameter’)) ?


How about simply adding hidden input field in form?


Hi Imants,

can’t really figure how that helps me determine in onSubmit() where the submit was triggered from.

Actually I have another Idea for a workaround with the supernice, but complicated AutoCompletes: A Form inside a Form, only for the AutoComplete. something like:

$form = $app->add(['Form']); //The normal Form
$form_ac = $form->layout->add(['Form']); //Form only for the AutoComplete
$ac = $form_ac->addField('add_guest', ['AutoComplete', ....include custom JS onChange form submit....]);

     ...handle what a change of Autocomplete should do

I will give it a try later, seems a sensible way to work around the flaws of AutoComplete field.


something like this:

$button->on(‘click’, [ $field->jsInput()->val(1); $form->js()->form(‘submit’); ]);

But yes, knowing which form submitted the button is obviously very useful.


This is getting nasty… I thought that a form exclusively for the autocomplete inside the actual form would be the most sensible way to go. But: HTML forbids nested forms…


Finally made it by restructuring the page and adding an extra form only for the AutoComplete :slight_smile: