File tree Expand file tree Collapse file tree 4 files changed +45
-18
lines changed Expand file tree Collapse file tree 4 files changed +45
-18
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,21 @@ The ``BaseType`` class is the parent class for both the ``button`` type
3131and the :doc: `FormType </reference/forms/types/form >`, but it is not part
3232of the form type tree (i.e. it cannot be used as a form type on its own).
3333
34- .. include :: /reference/forms/types/options/button_attr.rst.inc
34+ attr
35+ ~~~~
36+
37+ **type **: ``array `` **default **: ``array() ``
38+
39+ If you want to add extra attributes to the HTML representation of the button,
40+ you can use ``attr `` option. It's an associative array with HTML attribute
41+ as a key. This can be useful when you need to set a custom class for the button::
42+
43+ use Symfony\Component\Form\Extension\Core\Type\ButtonType;
44+ // ...
45+
46+ $builder->add('save', ButtonType::class, array(
47+ 'attr' => array('class' => 'save'),
48+ ));
3549
3650.. include :: /reference/forms/types/options/button_disabled.rst.inc
3751
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -26,7 +26,21 @@ A button that resets all fields to their original values.
2626Inherited Options
2727-----------------
2828
29- .. include :: /reference/forms/types/options/button_attr.rst.inc
29+ attr
30+ ~~~~
31+
32+ **type **: ``array `` **default **: ``array() ``
33+
34+ If you want to add extra attributes to the HTML representation of the button,
35+ you can use ``attr `` option. It's an associative array with HTML attribute
36+ as a key. This can be useful when you need to set a custom class for the button::
37+
38+ use Symfony\Component\Form\Extension\Core\Type\ResetType;
39+ // ...
40+
41+ $builder->add('save', ResetType::class, array(
42+ 'attr' => array('class' => 'save'),
43+ ));
3044
3145.. include :: /reference/forms/types/options/button_disabled.rst.inc
3246
Original file line number Diff line number Diff line change @@ -37,7 +37,21 @@ useful when :doc:`a form has multiple submit buttons </form/multiple_buttons>`::
3737Inherited Options
3838-----------------
3939
40- .. include :: /reference/forms/types/options/button_attr.rst.inc
40+ attr
41+ ~~~~
42+
43+ **type **: ``array `` **default **: ``array() ``
44+
45+ If you want to add extra attributes to the HTML representation of the button,
46+ you can use ``attr `` option. It's an associative array with HTML attribute
47+ as a key. This can be useful when you need to set a custom class for the button::
48+
49+ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
50+ // ...
51+
52+ $builder->add('save', SubmitType::class, array(
53+ 'attr' => array('class' => 'save'),
54+ ));
4155
4256.. include :: /reference/forms/types/options/button_disabled.rst.inc
4357
You can’t perform that action at this time.
0 commit comments