Other option always on top but between select and options in lists!

Created on 4 July 2020, almost 5 years ago
Updated 24 April 2025, 2 days ago

Created a custom module so the Other option (select_or_other) is listed after the select/none item and before the existing options (from the other field values).

Making it easier to select 'Other' option (custom entries) being the first option underneath instead of listed above/ontop.
Also better then 'Other' as default since one gets used to selecting underneath in a list, where also existing values are listed.

Might be a better alternative to the " Other "button" always on top " module.

Tested with 7.x-3.0-alpha3+1-dev using select list. Not tested with checkboxes/radio buttons or other version.
Anybody keen to test it and with other versions/widget? I'm happy to help and release it as a module thereafter.

Note: In my screenshots you can see the optional checkbox to add the other value to the list Make "add value to list" a choice for end-user (only for reuse) Closed: outdated that I also created and think is better in some cases then making it default for all fields (to avoid unnecessary values that won't be reused) as one has to make a conscious decision if a custom value is required and whether it should be added or not. .

Real life example:

CODE for custom module select_or_other_between_selectandoptions:

select_or_other_between_selectandoptions.info

name = Select or other between select and options
description =  <b>Other option (select_or_other) is listed after the select/none item and before the options(other field values).</b><br>Making it easier to select 'Other' (custom entries) being the first option underneath instead of listed above/ontop.<br>Also better then 'Other' as default since one gets used to selecting underneath where also existing values are listed.
package = Custom
core = 7.x

version = "7.x"

select_or_other_between_selectandoptions.module

<?php

/**
 * Implements hook_preprocess_HOOK().
 */
function select_or_other_between_selectandoptions_preprocess_select_or_other(&$variables) {

  $original_options = $variables['element']['select']['#options'];
  $select_removed = array('' => array_shift($original_options));
  $select_or_other_removed['select_or_other'] = array_pop($original_options);
  $variables['element']['select']['#options'] = $select_removed + $select_or_other_removed + $original_options;

}
Feature request
Status

Closed: outdated

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024