CakePHP-Bootstrap / cakephp3-bootstrap-helpers

CakePHP 3.x Helpers for Bootstrap 3 and 4.
https://holt59.github.io/cakephp3-bootstrap-helpers/
MIT License
130 stars 79 forks source link

Fix input type reset #184

Closed alphp closed 4 years ago

alphp commented 4 years ago

$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>

Holt59 commented 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?

alphp commented 4 years ago

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]);

Holt59 commented 4 years ago

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:

alphp commented 4 years ago

Workaround finded. Using "templates" option: php $this->Form->control(__('Reset'), ['type' => reset, 'templates' => ['input' => '<input type="{{type}}"{{attrs}}>'], class => 'btn btn-default btn-sm']);