-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Symfony Form Component: ChoiceType: add possibility for placeholder to be disabled #22318
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
Comments
Any news here? Could someone please say "yay" or "nay" so I can go ahead and implement it or drop the issue? |
Hello @elHornair, thank you for opening this issue. I don't really understand the need to set the placeholder disabled, because in cases where the choice is single (expanded or not), we have to be able to select it to unselect the other choices. Such feature concerns only multiple choices, but placeholder is not used for multiple choices (ref https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php#L295). Anyway, in very specific cases like that, I would go by setting the If you really need wide support in your app before it's in the core, you can easily create an extension for the ChoiceType to add an option, let's say if ($options['expanded'] && options['disable_placeholder'] && $builder->has('placeholder')) {
$builder->get('placeholder')->setDisabled(true);
} I'm not sure that handling this globally in the framework is worth it so I'm waiting for more feedback. |
Thanks for your reply @HeahDude.
That's the thing: if Also, thanks for your two suggestion - Both of these would work for me as a workaround. However I'd rather fix it in the core as others might benefit from it as well |
Thank you for this suggestion. |
Hello? This issue is about to be closed if nobody replies. |
I think adding something like a |
@xabbuh Hi! Sorry, I'm not actively using Symfony anymore and I don't remember what this issue was originally about. As far as I'm concerned the issue can either be closed or fixed in any way you see fit :) |
Thank you for the feedback. I am closing here then. We can consider to reopen if someone runs into it again in the future. |
Hello, for me it also would be a useful feature. The |
I found this while trying to figure out why placeholders weren't disabled by default when the select field is required. I'm surprised to discover not only is it by design, but so few people are inquiring about it. I'd go for the |
Currently, the placeholder of the Symfony Form components ChoiceType doesn't allow to set the rendered option in the HTML select to disabled. This is a use case however, because we don't always want the placeholder to be selectable (probably on the contrary). I see two ways how this could be fixed:
I can go ahead and create a PR, but I first wanted to hear your thoughts about it. Personally, I think option 2 is better. Wdyt?
The text was updated successfully, but these errors were encountered: