Closed alphp closed 4 years ago
If you want reset buttons, you need to use submit
: https://book.cakephp.org/3.0/en/views/helpers/form.html#creating-buttons-and-submit-elements
What do you get with submit
?
If you add the button individually then if you can use Submit instead of Input. However, if you use Controls to add several inputs at once, then that is when Control must detect if it is a Reset button.
$this->Form->controls($fieldset, ['legend' => false]);
I see what you mean, but in this case it's a CakePHP bug, so you should PR on their side. There are special "handlings" for submit
in control()
(and indirectly in _getInput
) which are not manager for reset()
, so you should open an issue / submit a PR directly to CakePHP.
In particular:
reset
reset
or a new function called reset
so that $this->{$options['type']}($fieldName, $options);
actually works.Workaround finded.
Using "templates" option:
php $this->Form->control(__('Reset'), ['type' => reset, 'templates' => ['input' => '<input type="{{type}}"{{attrs}}>'], class => 'btn btn-default btn-sm']);
$this->Form->control(__('Reset'), ['type' => reset, class => 'btn btn-default btn-sm']); Adds to input class form-control. Before:
<div class="form-group"><input type="reset" class="form-control btn btn-default btn-sm" value="Reset"></div>
After:<div class="form-group"><input type="reset" class="btn btn-default btn-sm" value="Reset"></div>