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

Skip to content

[Form] Add option widget to ChoiceType #15053

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

bamarni
Copy link
Contributor

@bamarni bamarni commented Jun 21, 2015

Q A
Bug fix? [no]
New feature? [yes]
BC breaks? [no]
Deprecations? [yes]
Tests pass? [yes]
Fixed tickets #6602
License MIT

Adding the behavior described here #6602, with another approach regarding radios and checkboxes though. When trying to implement it I noticed that the "multiple" option was kinda conflicting with the radio and checkbox widgets, because its value is implicit with them. So I think it would be better to stick to a more generic widget called "expanded", and the multiple option will decide whether it's a radio or a checkbox, it's similar to what we have currently and easier to implement. What do you think @webmozart?

Then I'll only need to rebase the old changes in #8112 about the entity type and it should be ok :)

@webmozart
Copy link
Contributor

Thanks for working on this @bamarni! You are right, the "multiple" option is implicitly set when "widget" is set. In fact, "multiple" and "expanded" should be deprecated and replaced by "widget".

As soon as "widget" is set, "multiple" and "expanded" should not have any effect.

@bamarni
Copy link
Contributor Author

bamarni commented Jun 22, 2015

What about the "text" widget then? In that case "multiple" was supposed to
decide wether it's a plain value or values separated by a delimiter.

2015-06-22 13:06 GMT+02:00 Bernhard Schussek [email protected]:

Thanks for working on this @bamarni https://github.com/bamarni! You are
right, the "multiple" option is implicitly set when "widget" is set. In
fact, "multiple" and "expanded" should be deprecated and replaced by
"widget".

As soon as "widget" is set, "multiple" and "expanded" should not have any
effect.


Reply to this email directly or view it on GitHub
#15053 (comment).

@webmozart
Copy link
Contributor

Ah good point :) Same for select, in fact. What about ignoring "multiple" then (and using a default) if "widget" is "checkbox" or "radio"?

@bamarni bamarni force-pushed the form-choice-widget-option branch 5 times, most recently from 31591d9 to b133772 Compare July 5, 2015 10:45
@bamarni bamarni changed the title [WIP][Form] Add option widget to ChoiceType [Form] Add option widget to ChoiceType Jul 5, 2015
@bamarni
Copy link
Contributor Author

bamarni commented Jul 5, 2015

@webmozart : While switching to "radio/checkbox" widgets I've faced an issue when adding a normalizer for the "multiple" option (cyclic reference). I think the only way to keep full BC here is to make the 'widget' option normalizing 'expanded' and 'multiple', without touching the code behind all this. Then we'll update the code when breaking BC, and set a normalizer for "multiple". What do you think? (cf. second commit).

@bamarni bamarni force-pushed the form-choice-widget-option branch from b133772 to a63e3c2 Compare July 5, 2015 10:55
@Koc
Copy link
Contributor

Koc commented Sep 28, 2015

Any change for getting this merged in 2.8?

@fabpot
Copy link
Member

fabpot commented Sep 28, 2015

@Koc Unfortunately, we are waiting for @webmozart review.

public function transform($array)
{
if (null === $array) {
return array();
Copy link
Contributor

Choose a reason for hiding this comment

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

return ''; ?

@bamarni bamarni force-pushed the form-choice-widget-option branch 2 times, most recently from 8fcf9fa to 296ec8d Compare November 29, 2015 09:27
@bamarni
Copy link
Contributor Author

bamarni commented Nov 29, 2015

I just rebased and added more tests. According to the roadmap, now this can only land in the 3.X series right?

@bamarni bamarni force-pushed the form-choice-widget-option branch from 296ec8d to 5477d08 Compare November 29, 2015 10:09
@bamarni bamarni force-pushed the form-choice-widget-option branch from 5477d08 to 02b1768 Compare November 30, 2015 09:47
@fabpot
Copy link
Member

fabpot commented Jan 27, 2016

@webmozart Can you have a look at this one? The related issue is very old now with quite a few supporters. If we want it for 3.1, we should finish it as soon as possible.

@bamarni
Copy link
Contributor Author

bamarni commented Jan 27, 2016

@fabpot 👍 From my pov except for the rebase it's finished, I was just waiting for feedback.


protected function setUp()
{
$this->transformer = new ValuesToStringTransformer(',', true);
Copy link
Member

Choose a reason for hiding this comment

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

We should have tests for other delimiters too.

@bamarni
Copy link
Contributor Author

bamarni commented Feb 1, 2016

@fabpot @xabbuh : I've rebased it against master here #17646, really looking forward to have this in 3.1, let me know if there's anything still missing.

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

Successfully merging this pull request may close these issues.

6 participants