Problem/Motivation

Thank you for the cshs_menu_link submodule, it came just in time for me. That said I'm not sure if the string "- Please select -" is optimal for this context. To me, as end user, it suggests that I should make a choice. In fact, making a choice is optional.

Proposed resolution

Consider if there is a better way to communicate that the user can make a choice, but does not have to. It should be clear to the end user what the effect of both options is.

Issue fork cshs-3199357

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:

Comments

marcvangend created an issue. See original summary.

andy-blum’s picture

Title: Reconsider choice of words "- Please select -" » Make default option label configurable
Category: Task » Feature request
Issue summary: View changes

I think this issue is effectively a duplicate of #2606760: "Make the default option label configurable", but I'm going to mark the other one as a duplicate of this because that issue is old on on the 7.x branch.

From that comment thread from user lahode:

/**
 * Implements hook_field_widget_form_alter()
 */
function my_module_field_widget_form_alter(&$element, &$form_state, $context) {  
  if ($context['field']['field_name'] == 'field_myfield') {
    if (isset($element['tid']['#options']['_none'])) {
      $element['tid']['#options']['_none'] = t('- Please select your term -');
    }
  }
}

/**
 * Implements hook_element_info_alter()
 */
function my_module_element_info_alter(&$type) {
  // Decrease the default size of textfields.
  if (isset($type['cshs'])) {
    $type['cshs']['#none_label'] = t('- Please select your term -');
  }
}
marcvangend’s picture

Thanks Andy. In fact I'm using a form alter at the moment to override '#none_label' only in the menu link situation. I was happy to find this works well:

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function MODULE_form_node_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
  if ($form['menu']['link']['menu_parent']['#type'] === 'cshs') {
    $form['menu']['link']['menu_parent']['#none_label'] = t('- Select a deeper level -');
  }
}

I guess making it configurable is a good idea too. That said, it still wouldn't hurt to try and figure out what the optimal default value is.

br0ken’s picture

I see no easy-to-implement option and don't want to complicate this module really. Any propositions?

marcvangend’s picture

Re @BR0kEN: I understand your concerns about adding complexity. The suggestion and title change in #2 considerably broadened the scope of this issue, so for now I'll just focus on my original point: "a better way to communicate that the user can make a choice, but does not have to".

My most minimalist suggestion would be: Change the slightly opinionated "- Please select -" to a neutral "- Select -".

In addition, still low complexity: In cshs_menu_link_form_node_form_alter(), add a #description property to guide the user. For instance:

$element['#description'] = t('The menu link is created below the selected menu item. Optionally, select additional levels to place the link deeper in the menu structure.');

  • BR0kEN committed def4786 on 8.x-2.x
    Issue #3199357 by BR0kEN, marcvangend, andy-blum: Make default option...
br0ken’s picture

Status: Active » Fixed

Thanks @marcvangend, @andy-blum. The label is now configurable for a field widget and replaced with - Select - for cshs_menu_link submodule. The description proposed in #5 added as well.

marcvangend’s picture

Thank you for the quick response!

Status: Fixed » Closed (fixed)

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