Skip to content

Commit e423118

Browse files
committed
[Form customization] added block_name example.
1 parent 55442b5 commit e423118

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

cookbook/form/form_customization.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,25 @@ field whose *id* is ``product_name`` (and name is ``product[name]``).
660660
``ProductType`` equates to ``product``). If you're not sure what your
661661
form name is, just view the source of your generated form.
662662

663+
If you want to change the ``product`` or ``name`` portion of the block
664+
name ``_product_name_widget`` you can set the ``block_name`` option in your
665+
form type:
666+
667+
.. code-block:: php
668+
669+
use Symfony\Component\Form\FormBuilderInterface;
670+
671+
public function buildForm(FormBuilderInterface $builder, array $options)
672+
{
673+
// ...
674+
675+
$builder->add('name', 'text', array(
676+
'block_name' => 'custom_name'
677+
));
678+
}
679+
680+
The block name can then be ``_product_custom_name_widget``
681+
663682
You can also override the markup for an entire field row using the same method:
664683

665684
.. configuration-block::

0 commit comments

Comments
 (0)