Skip to content

[Form] "Fragment Naming for Single Radio Button / Checkbox Entries" #13573

Closed
@ThomasLandauer

Description

@ThomasLandauer

The _entry_ part for radio buttons and check boxes isn't documented at all - I only learned from symfony/symfony#36489 that they exist.

So I'm suggesting a new heading "Fragment Naming for Single Radio Button / Checkbox Entries" above https://symfony.com/doc/4.4/form/form_themes.html#fragment-naming-for-collections

Two other things that are missing on that page - if somebody gives me answers, I'll come up with a PR :-)

  • When following the _id_part pattern https://symfony.com/doc/4.4/form/form_themes.html#fragment-naming-for-individual-fields ,
    parent() is not working.
    I tried to copy the contents of {% block radio_widget -%} to such a custom fragment and received:

    The template has no parent and no traits defining the "_form_gender_entry_widget" block.

    Is this just some special case or will it never work? Any workaround (like manually defining the parent)?

  • What's the difference between block_name and block_prefix?
    I'm guessing: block_name is just for this single field in the entire app (since it's prefixed with the form name). So if you have 3 such fields (in 3 forms), you'd have to copy your custom block three times? And this is were block_prefix comes as rescue - now you omit the form name and are able to address all 3 of them simultaneously? => If that's the case, the message doesn't really come across in https://symfony.com/doc/4.4/form/form_themes.html#fragment-naming-for-individual-fields

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions