Skip to content

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 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 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion reference/forms/types/options/choice_value.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ 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 "See choice_label_ for similar usage. completely. This would avoid talking about "differences" with the other options.

If ``null`` is used, an incrementing integer is used as the name.
*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 misses choice_attr (and maybe future other(s) ;).

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


.. caution::

Expand Down