Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Form] FixChoiceType options#6393

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@HeahDude
Copy link
Contributor

QA
Doc fix?yes
New docs?no
Applies toall
Fixed tickets#6144

'choices_as_values' => true,
'data' => true, // pre selected choice
'empty_data' => '1', // default submitted value
));
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Should we detail that whenmultiple it should be:

'data' =>array(true),'empty_data' =>array('1'),

??

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Refsymfony/symfony#18817.

This clearly needs to explained.

xabbuh reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

Man, this note basically doesn't make any sense to me :). I don't think it's your fault - I just find this choice stuff really hard. What exactly is the problem that we're trying to warn the user about? The only issue I can understand is thatempty_data (if you want to set that) would need to equal1 to simulatetrue (I think, because apparently these values will render as 0, 1, 2 because they can't be cast into strings?).

I'm normally under the impression that the user will rarely care about the HTML value attribute that is rendered/submitted - as long as if I select "Yes", I end up withtrue in my code.

@HeahDudeHeahDudeforce-pushed thefix-choice_type-options-allowed_types branch 4 times, most recently from6da211f tob49bb5aCompareMarch 26, 2016 01:23
fabpot added a commit to symfony/symfony that referenced this pull requestMar 30, 2016
This PR was merged into the 2.7 branch.Discussion----------[Form] remove useless copy in ChoiceType| Q             | A| ------------- | ---| Branch?       | 2.7+| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        |symfony/symfony-docs#6393`ChoiceListFactoryInterface` expected `$groupBy` to be a callable or null, not an array ([ref](https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php#L111)).The factory defaults `groupBy` to `ChoiceListInterface::getStructuredValues()` ([ref](https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php#L122)).Hence, the copy of the choices array and the recursive flip are useless and may be slowing down performances imho (especially with `EntityType`).Commits-------562f5e4 [Form] remove useless code in ChoiceType
symfony-splitter pushed a commit to symfony/form that referenced this pull requestMar 30, 2016
This PR was merged into the 2.7 branch.Discussion----------[Form] remove useless copy in ChoiceType| Q             | A| ------------- | ---| Branch?       | 2.7+| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        |symfony/symfony-docs#6393`ChoiceListFactoryInterface` expected `$groupBy` to be a callable or null, not an array ([ref](https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.php#L111)).The factory defaults `groupBy` to `ChoiceListInterface::getStructuredValues()` ([ref](https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php#L122)).Hence, the copy of the choices array and the recursive flip are useless and may be slowing down performances imho (especially with `EntityType`).Commits-------562f5e4 [Form] remove useless code in ChoiceType
@HeahDude
Copy link
ContributorAuthor

This one needs reviews :)


..note::

Pre selected choices will depend on the **data** passed to field and the values of
Copy link
Contributor

@alexislefebvrealexislefebvreMay 10, 2016
edited
Loading

Choose a reason for hiding this comment

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

@HeahDude Should it bePreselected?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Je ne sais pas :) I would natively say "pré-selectionné" with a dash.

alexislefebvre reacted with thumbs up emojialexislefebvre reacted with laugh emoji

Choose a reason for hiding this comment

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

In case of doubt, our official reference is the "American English Oxford Dictionary":preselected is correct.

alexislefebvre and HeahDude reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thank you very much@javiereguiluz! Reference added in my favorites :)

@HeahDudeHeahDudeforce-pushed thefix-choice_type-options-allowed_types branch fromb49bb5a to5430cecCompareJune 25, 2016 17:20
@HeahDude
Copy link
ContributorAuthor

Comments addressed.

Status: Needs Review

Finally, if your values are objects, you can also specify a property path string
on the object that will return true or false.

See the `choice_label`_ for details about using a property path or a callable.
Copy link
Member

Choose a reason for hiding this comment

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

This reference doesn't work.


Also, the:class:``Symfony\\Component\\Form\\ChoiceList\\Factory\\ChoiceListFactoryInterface`` will cache the choice list
so the same:class:``Symfony\\Component\\Form\\ChoiceList\\Loader\\ChoiceLoaderInterface`` can be used in different fields with more performance
(reducing N queries to 1).
Copy link
Member

Choose a reason for hiding this comment

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

minor: a few of these lines got real long :)

@HeahDude
Copy link
ContributorAuthor

@weaverryan thanks for the review!

Status: Needs Work

Pre selected choices will depend on the **data** passed to the field and
the values of the ``choices`` option. However submitted choices will depend
on the **string** matching the **choice**. In the example above, the default
values are incrementing integers because ``null`` cannot be casted to string.
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@ycerutoycerutoJan 4, 2017
edited
Loading

Choose a reason for hiding this comment

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

In fact, I think it's a bug ;) we can show"", "1", "0" values forarray(null, true, false) choices and be more consistent.

Trying to fix that insymfony/symfony#21160

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

As said in your PR you should close it, this is why this needs a better doc :)

yceruto reacted with thumbs up emoji
'No' => false,
),
'choices_as_values' => true,
'data' => true, // pre selected choice
Copy link
Member

Choose a reason for hiding this comment

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

This should be a bad practice. The reader could interpret that is a way to set default value and it isn't. As you know, if an object is bound to the form, thedata option overrides this default value.

I suggest you to use$this->createFormBuilder(array('isAttending' => true)) from a controller for this sample. WDYT?

Copy link
ContributorAuthor

@HeahDudeHeahDudeJan 4, 2017
edited
Loading

Choose a reason for hiding this comment

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

@yceruto I understand your comment but this is not about a bad practice here, it's about making a clear difference as I'm not sure#6265 is enough though.

@weaverryan
Copy link
Member

Ping@HeahDude! Could you go through my review and finish this? Thx!

codedmonkey added a commit to codedmonkey/symfony-docs that referenced this pull requestFeb 22, 2018
@javiereguiluzjaviereguiluz modified the milestones:2.7,2.8May 28, 2018
@xabbuhxabbuh modified the milestones:2.8,3.4Nov 28, 2018
fabpot added a commit to symfony/symfony that referenced this pull requestMar 17, 2019
This PR was merged into the 3.4 branch.Discussion----------[Form] Fixed some phpdocs| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | ~| License       | MIT| Doc PR        |symfony/symfony-docs#6393refsymfony/symfony-docs#6144,symfony/symfony-docs#6297,#14050Commits-------b9162e8 [Form] Fixed some phpdocs
@javiereguiluz
Copy link
Member

It's sad but this pull request is no longer mergeable. Things have changed too much and there are too many conflicts. We can open a new pull request in the future and get some inspiration from this one. I'm sorry for having let this pull request stale and thanks anyway for the contribution.

OskarStark added a commit that referenced this pull requestFeb 18, 2020
This PR was squashed before being merged into the 3.4 branch.Discussion----------[Form] minor fixes in ChoiceType optionsRevival of#6393Commits-------4ee4102 [Form] minor fixes in ChoiceType options
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@ycerutoycerutoyceruto left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

7 participants

@HeahDude@weaverryan@javiereguiluz@xabbuh@yceruto@alexislefebvre@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp