Skip to content

[Form] Added choice_entry, checkbox_entry and radio_entry to ChoiceType entries #36489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

HeahDude
Copy link
Contributor

@HeahDude HeahDude commented Apr 18, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets ~
License MIT
Doc PR TODO

I had the idea when I started working on #36088, but #36484 lit the fire (ping @ThomasLandauer :)).

Allows to use choice_entry_* blocks to customize all choice entries (whether radio or checkbox) for all types, in addition (and with precedence) of the dynamic _form_name_choice_field_name_entry_*.

Plus specific type of entries with checkbox_entry_* and radio_entry_* blocks.

So the order is now looked up like this (from last to first):

$choiceCheckBoxPrefixes = [
    'form', // as before
    'checkbox', // all checkboxes and radios, as before
    'choice_entry', // all fields (radio and checkbox) nested in choice lists
    'checkbox_entry', // all checkboxes nested in choice lists
    '_form_name_choice_field_name_entry',  // as before
];

$choiceRadioPrefixes = [
    'form', // as before
    'checkbox', // all checkboxes and radios, as before
    'radio', // all radios, as before
    'choice_entry', // all fields (radio and checkbox) nested in choice lists
    'radio_entry', // all radios nested in choice lists
    '_form_name_choice_field_name_entry',  // as before
];

@ThomasLandauer
Copy link
Contributor

Does this mean that you can set an option radio_entry like at
https://symfony.com/doc/current/form/form_themes.html#custom-fragment-naming-for-individual-fields
to control the rendering of each individual radio button via a block in a custom form theme?

@HeahDude
Copy link
Contributor Author

Yes for all choice entries or for specific type of choice entries. A sibling of #36088.

@ThomasLandauer
Copy link
Contributor

Great!! But it will apply to all radios belonging to that field?! So #36484 is still the way to go to manipulate individual radios?

@HeahDude
Copy link
Contributor Author

HeahDude commented Apr 18, 2020

Ok I've updated the description to explain what this PR enables exactly.


$expectedBlockPrefixes = [
'form',
'checkbox',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we expect the checkbox prefix here?

/**
* Appends a block prefix after the static defaults and before dynamic ones.
*/
public static function appendStaticBlockPrefix(FormView $view, string $prefix, bool $decreaseOffset): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not add this method. To me it decreases readability a lot to not just see in place how array_splice() is used.

@fabpot
Copy link
Member

fabpot commented Aug 18, 2020

@HeahDude What's the status here? Can you take comments into account?

@fabpot
Copy link
Member

fabpot commented Sep 7, 2020

Closing for now as the PR is stale. Feel free to reopen when you have time. Thank you.

@fabpot fabpot closed this Sep 7, 2020
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.2 Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants