Reputation: 350
I created a form input
$this->add(array(
'name' => 'submit',
'attributes' => array(
'type' => 'submit',
'value' => 'UserRestorePassword.Restore',
'id' => 'submitbutton',
'class' => 'btn btn-primary btn-sm',
'style' => 'padding: 7px 35px;'
),
));
And this generates:
<input name="submit" type="submit" id="submitbutton" class="btn btn-primary btn-sm" style="padding: 7px 35px;" value="Restore">
In view:
<?=$this->translate($this->formSubmit($form->get('submit')));?>
How to get Restore
value from this form?
Upvotes: 1
Views: 4114
Reputation: 321
from https://stackoverflow.com/a/12367718/468891 :
If you need the value from the form which has been assigned previously, you can access it using
$form->get('elementName')->getValue(); However, if you're using InputFilters, you need to fetch it using
$form->getInputFilter()->getValue('name');
Otherwise, the value you're retrieving was not passed through the filters.
Upvotes: 3
Reputation: 11447
If you just want the value
attribute of the submit
element, call the getValue
method for that element
$value = $form->get('submit')->getValue(); // = UserRestorePassword.Restore
Upvotes: 5