Skip to content

Commit a5ea888

Browse files
committed
minor #7824 Fixed the form types of the buttons in the Form reference (javiereguiluz)
This PR was squashed before being merged into the 2.8 branch (closes #7824). Discussion ---------- Fixed the form types of the buttons in the Form reference This fixes #6864. Commits ------- 7239fb9 Fixed the form types of the buttons in the Form reference
2 parents ce1b83d + 7239fb9 commit a5ea888

File tree

4 files changed

+45
-18
lines changed

4 files changed

+45
-18
lines changed

reference/forms/types/button.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,21 @@ The ``BaseType`` class is the parent class for both the ``button`` type
3131
and the :doc:`FormType </reference/forms/types/form>`, but it is not part
3232
of 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

reference/forms/types/options/button_attr.rst.inc

Lines changed: 0 additions & 15 deletions
This file was deleted.

reference/forms/types/reset.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,21 @@ A button that resets all fields to their original values.
2626
Inherited 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

reference/forms/types/submit.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,21 @@ useful when :doc:`a form has multiple submit buttons </form/multiple_buttons>`::
3737
Inherited 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

0 commit comments

Comments
 (0)