Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] EnhancedChoiceType #3456

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
pulzarraider opened this issue Feb 26, 2012 · 5 comments
Closed

[Form] EnhancedChoiceType #3456

pulzarraider opened this issue Feb 26, 2012 · 5 comments

Comments

@pulzarraider
Copy link
Contributor

Now Form's ChoiceType accept only key=>value array and can render only simple list of choices without any parameters or additional informations.

It would be great if there will be EnhancedChoiceType which will accept more complicated array of values (key, label, custom attributes, level etc.).

EnhancedChoiceType will be used to render:

  • nested choices (tree of choices):
radioButton_A
    radioButtonChild_A_1
    radioButtonChild_A_2
    radioButtonChild_A_3
radioButton_B
    radioButtonChild_B_1
    radioButtonChild_B_2
...
  • choices with attributes:
<option rel="auto" disabled="disabled">aaaaa</option>
<option rel="moto">bbbbb</option>
<option rel="moto" data-id="123">ccccc</option>
...
<input type="radio" ... disabled="disabled" data-id="123">

This issue is reopening #2754 as I think forms should deal with this by default.

@stof
Copy link
Member

stof commented Apr 3, 2012

@bschussek what do you think about it ?

@webmozart
Copy link
Contributor

The first point is already possible by using the "group_by" option of EntityType. As for the second, I need to research whether this is possible, but it should be.

@webmozart
Copy link
Contributor

Ah, I misread. So you want to extend ChoiceType. What's the use case for a tree-like choices array? (I assume you don't talk about option groups right?)

@pulzarraider
Copy link
Contributor Author

OptGroups are good to group choices and are usable too. But in tree of choices root elements have to be selectable too. In optgroup this is not possible, as they are only labels.

Here are some common use cases:

  • root directory with subdirectories and their subdirectories,
  • menu and submenu (where to add new page),
  • regions, districts and their cities (region or district can be also selected),
  • tree of payment methods (direct payment methods like PayPal,CardPay, offline payment methods...),
  • tree of categories in eshop (where to add new product).

To make tree of choices more visually attractive, javascript can be used to hide nested choices (and show them only when parent is selected), to select all child choices when parent is selected. Of course, this is task for programmer, not for the FormComponent.

Anyway, more important is to have choices with custom attributes.

@webmozart
Copy link
Contributor

@pulzarraider Thanks for your feedback. I created two new issues for these feature requests (see above). Please check them if they fit your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants