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] Added information about float choice lists#4241

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

Closed
peterrehm wants to merge1 commit intosymfony:2.5frompeterrehm:patch-1
Closed

[Form] Added information about float choice lists#4241

peterrehm wants to merge1 commit intosymfony:2.5frompeterrehm:patch-1

Conversation

peterrehm
Copy link
Contributor

QA
Doc fix?no
New docs?no
Applies toall
Fixed tickets-

Added an information about the possibility to have a choice list with float values.

Relates tosymfony/symfony#11849

@peterrehmpeterrehm changed the titleAdded information about float choice lists[Form] Added information about float choice listsSep 17, 2014
@stof
Copy link
Member

note that this is also useful to choose boolean values, ornull (anything other than strings and integers actually, as they cannot be array keys)

With this option you can also allow float values to be selected as data.::

$builder->add('status', 'choice', array(
'choice_list' => new ChoiceList(array(1, 0.5), array('Full', 'Half')
Copy link
Member

Choose a reason for hiding this comment

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

you should add the use statement

@peterrehm
Copy link
ContributorAuthor

Thank you for the information, just updated accordingly and squashed the commits.

(e.g. a float or a boolean) you should us the ``choice_list`` option instead.
With this you can keep the original data format. This is also important to ensure
proper validation and to avoid useless Database updates potentially caused by a
wrong data type.
Copy link
Member

Choose a reason for hiding this comment

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

I think we can rephrase this a bit (and also link to thechoice_list option):

..tip::    When the values to choose from are not integers or strings (but e.g. floats    or booleans), you should use the `choice_list`_ option instead. With this    option you are able to keep the original data format which is important    to ensure that the user input is validated properly.

I'm not sure if the part about database updates is that important. What do you think about this?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think the doctrine update should be mentionned. It is not even the main issue. There is worse than the noop update: in case of edition, the wrong value will be initially selected when using the wrong type, because Symfony uses strict comparison to choose the value

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Well I am unsure about this. However as a side effect you have those updates which might cause updated timestamps, called listeners just based on an altered value. I have added it again to raise awareness, however I am fine with removing it. You guys can decide.

@weaverryan
Copy link
Member

This is a nice note - I've merged it into the 2.3 branch. Thanks Peter!

@peterrehmpeterrehm deleted the patch-1 branchOctober 20, 2014 14:36
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@peterrehm@stof@weaverryan@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp