Problem/Motivation

On #2779999: Document checkboxes and radios element can have individual descriptions it was pointed out that the sample code for checkboxes and radios form elements is culturally specific. @quietone wrote in the MR review:

I am concerned that both 'high_school' and 'SAT' are culturally specific and may not mean much to anyone outside of countries that have high schools and use the 'SAT' test. I spoke to xjm and she thought 'high_school' was acceptable and then reminded me of the controversy about the 'SAT' test being biased, such as racially, economically, and gender. Therefor, let's use a different example.

The current example code is:

 * Usage example:
 * @code
 * $form['high_school']['tests_taken'] = array(
 *   '#type' => 'checkboxes',
 *   '#options' => array('SAT' => $this->t('SAT'), 'ACT' => $this->t('ACT')),
 *   '#title' => $this->t('What standardized tests did you take?'),
 *   ...
 * );
 * @endcode
 *
 * Element properties may be set on single option items as follows.
 *
 * @code
 * $form['high_school']['tests_taken']['SAT']['#description'] = $this->t('Description for the SAT option.');
 * @endcode
 *

Proposed resolution

The terms used in the example code should be changed.

Remaining tasks

- Decide on what to use for an example
- Make a MR with the changes.

Issue fork drupal-3265929

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

lauriii’s picture

joachim’s picture

Issue summary: View changes
joachim’s picture

Issue summary: View changes

Let's start the bikeshed!

The obvious one seems to me to be 'What is your favourite colour?'

jonathanshaw’s picture

How's this:

* Usage example:
 * @code
 * $form['favorites']['colors'] = array(
 *   '#type' => 'checkboxes',
 *   '#options' => array('blue' => $this->t('Blue'), 'red' => $this->t('Red')),
 *   '#title' => $this->t('Which colors do you like?'),
 *   ...
 * );
 * @endcode
 *
 * Element properties may be set on single option items as follows.
 *
 * @code
 * $form['favorites']['colors']['blue']['#description'] = $this->t('The color of the sky.');
 * @endcode
joachim’s picture

Looks good!

jonathanshaw’s picture

Status: Active » Needs review

yogeshmpawar made their first commit to this issue’s fork.

joachim’s picture

Status: Needs review » Reviewed & tested by the community

LGTM!

xjm credited quietone.

xjm’s picture

Adding credit for @quietone who brought this up with me originally.

  • xjm committed 5d2d281 on 10.0.x
    Issue #3265929 by jonathanshaw, yogeshmpawar, quietone, xjm: Rewrite...

  • xjm committed 4e4d69c on 9.4.x
    Issue #3265929 by jonathanshaw, yogeshmpawar, quietone, xjm: Rewrite...

  • xjm committed 2f9239c on 9.3.x
    Issue #3265929 by jonathanshaw, yogeshmpawar, quietone, xjm: Rewrite...
xjm’s picture

Version: 9.4.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: +Needs followup

Tagging "Needs followup" for:

This also should be using short array syntax. ;) But that's out of scope for the issue as written, so someone can make a "Correct use of array() to [] in comments" issue to clean that up. (A CS rule already enforces it for code.)

Committed to 10.0.x and cherry-picked to 9.4.x. Thanks! I also backported it to 9.3.x as a patch-eligible documentation bugfix. (I had to backport #2779999: Document checkboxes and radios element can have individual descriptions first.)

Apologies to @joachim; I accidentally left off credit for your issue report in the commit message because I crossposted with myself when dealing with the backport blocker, but it's restored in the issue credit on the issue node here.

dww’s picture

dww’s picture

Ugh, silly me. I should have searched first. #2874067: Fix Drupal.Commenting.DocCommentLongArraySyntax coding standard is the real followup that we didn't need. ;)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.