-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Adding attributes to ChoiceView #9694
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
Conversation
@@ -19,6 +19,13 @@ | |||
class ChoiceView | |||
{ | |||
/** | |||
* Attributes who can be used in view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
who -> which
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed ;-)
This alone does not fix the ticket at all. It needs to be used and configurable in all relevant places |
@stof can you add some details ? Because this is first step to open the ChoiceView. |
@ruian this is indeed the first step. bBut in the current state, it does not fix the issue. More steps are needed, which would use the work done in your first commit |
@stof Which are the others steps, maybe i could update this PR. |
Well, attributes are ignored currently, amking them useless. So I see at least 2 steps:
|
You're right i will work on it. |
@@ -12,21 +12,23 @@ | |||
namespace Symfony\Component\Form\Extension\Core\Type; | |||
|
|||
use Symfony\Component\Form\AbstractType; | |||
use Symfony\Component\Form\Extension\Core\View\ChoiceView; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert the reordering of the use statements? That makes merging between branches a nightmare.
You forgot to also update the PHP templates. |
@bschussek What do you think of this feature? |
@fabpot Yeah sure i will update this PR asap |
Description: Because some times is usefull to add some attributes to select's options. Exemple when using, select2, chosen, or juste by adding some prototypes. | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#5286 | License | MIT
ping @stof can you give your feedback ? |
|
||
$choicesAttributes = $options['choices_attributes']; | ||
$choicesPrototypes = $options['choices_prototypes']; | ||
if (count($choicesAttributes) || count($choicesPrototypes)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not:
if (!empty($options['choices_attributes']) || !empty($options['choices_prototypes'])) {}
As you don't need to know how many choices exists, but just there are somem, also those new variable are useless (even you use only one of those).
thx @stloyd it's now fixed |
@@ -132,6 +156,19 @@ public function buildView(FormView $view, FormInterface $form, array $options) | |||
// POST request. | |||
$view->vars['full_name'] = $view->vars['full_name'].'[]'; | |||
} | |||
|
|||
if (!empty($options['choices_attributes']) || !empty($options['choices_prototypes'])) { | |||
$choicesAttributes = $options['choices_attributes']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of this variable? You are not manipulating that array, so IMO the is no real point of adding it and not working directly on $options['choices_attributes']
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
humm you must be right.
Closing in favor of #10309 |
Description:
Because some times is usefull to add some attributes to select's options. Exemple when using, select2, chosen, or juste by adding some prototypes.
Example :