Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit af8c20f

Browse filesBrowse files
committed
feature #3818 [Form customization] added block_name example. (aitboudad)
This PR was merged into the 2.3 branch. Discussion ---------- [Form customization] added block_name example. | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | all |Fixed tickets | - Commits ------- 512d5eb [Form customization] fixed minor typos e423118 [Form customization] added block_name example.
2 parents 4ed9a08 + 512d5eb commit af8c20f
Copy full SHA for af8c20f

File tree

Expand file treeCollapse file tree

1 file changed

+17
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+17
-0
lines changed

‎cookbook/form/form_customization.rst

Copy file name to clipboardExpand all lines: cookbook/form/form_customization.rst
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,23 @@ 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+
use Symfony\Component\Form\FormBuilderInterface;
668+
669+
public function buildForm(FormBuilderInterface $builder, array $options)
670+
{
671+
// ...
672+
673+
$builder->add('name', 'text', array(
674+
'block_name' => 'custom_name',
675+
));
676+
}
677+
678+
Then the block name will be ``_product_custom_name_widget``.
679+
663680
You can also override the markup for an entire field row using the same method:
664681

665682
.. configuration-block::

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.