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

clarify the signature of the choice_value callable#6297

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
backbone87 wants to merge3 commits intosymfony:2.7frombackbone87:patch-2

Conversation

@backbone87
Copy link
Contributor

QA
Doc fix?yes
New docs?no
Applies to2.7+
Fixed tickets

about this, but it might be handy when processing an API request (since you can
configure the value that will be sent in the API request).
This can be a callable or a property path. See `choice_label`_ for similar usage.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's better to remove"Seechoice_label_ for similar usage. completely. This would avoid talking about "differences" with the other options.

@HeahDude
Copy link
Contributor

👍 to be more explicit with this option.
Also, I've read in an issue that someone was missing the fact that it's an entity which is passed inEntityType. It would be nice to explicit the fact that it's the choice model data that is passed.
And a caution as this callable is also called with the default data which is oftennull or an empty string so it throws an exception if you used method on object choices.
Finally I would suggest to say something about the responsibility to return a unique string representation.

@backbone87
Copy link
ContributorAuthor

@HeahDude i agree with you on everything, but i think its out of scope for this PR, since it is just a quick doc fix, to avoid errors

#6144 requests a general overhaul / clarification of the choice type / choice list components

@HeahDude
Copy link
Contributor

Alright then ;) But at least, to quickly avoid errors, I hardly recommend to remove that line as I said in inline comment.

*If you use a callable for this option, it gets passed the choice as its **only**
argument*. This is a difference compared to the callables of `choice_label`_ and
`choice_name`_, which receive additional arguments. If ``null`` is used, an
incrementing integer is used as the name.
Copy link
Member

Choose a reason for hiding this comment

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

I agree that it would be best to have the section overhauled in general, but I also agree that this is a nice short-term fix. However, I suggest to change this a bit to something like this:

..note::    In contrast to the ``choice_label`` and ``choice_name`` option when using    a callable for the ``choice_value`` option, the actual choice is the **only**    argument passed to it.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

This is a detail but I would say :

..note::    In contrast to other choice options (e.g ``choice_label``), the callable for    the ``choice_value`` option takes as **only** argument the actual choice.

Because the actual enumeration misseschoice_attr (and maybe futureother(s) ;).

Anyway please removeSeechoice_label_ for similar usage., as I really think it can confuse new comers.

@backbone87
Copy link
ContributorAuthor

i have applied your feedback, can be autosquashed for clean history

In contrast to other choice options (e.g. `choice_label`_), the callable for
the ``choice_value`` option takes as **only** argument the actual choice, which
is also the value that gets passed to your model after submitting the form.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would replaceafter bywhen.

Beside that 👍

@backbone87
Copy link
ContributorAuthor

done

In contrast to other choice options (e.g. `choice_label`_), the callable for
the ``choice_value`` option takes as **only** argument the actual choice, which
is also the value that gets passed to your model when submitting the form.
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, but now I'm re-reading it and I think that", which is also the value that gets passed to your model when submitting the form" is too confusing. It better should be defined outside of this note, when clarifying the responsibility of this option to return a unique string representation of the choice.

Copy link
Member

Choose a reason for hiding this comment

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

@backbone87 Can you reword this a bit?

weaverryan added a commit that referenced this pull requestSep 27, 2017
…one87)This PR was squashed before being merged into the 2.7 branch (closes#6297).Discussion----------clarify the signature of the choice_value callable| Q | A || --- | --- || Doc fix? | yes || New docs? | no || Applies to | 2.7+ || Fixed tickets |  |Commits-------5cf83f6 clarify the signature of the choice_value callable
weaverryan added a commit that referenced this pull requestSep 27, 2017
@weaverryan
Copy link
Member

Thanks! I've just merged this, and tried to clarify further at sha:6365c01

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
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

@backbone87@HeahDude@weaverryan@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp