If an empty (null) value is submitted, it could be because no elements should be selected.
I believe form_type_multiselect_value should be more in line with form_type_select_value:

function form_type_select_value($element, $input = FALSE) {
  if ($input !== FALSE) {
    if (isset($element['#multiple']) && $element['#multiple']) {
      // If an enabled multi-select submits NULL, it means all items are
      // unselected. A disabled multi-select always submits NULL, and the
      // default value should be used.
      if (empty($element['#disabled'])) {
        return (is_array($input)) ? drupal_map_assoc($input) : array();
      }
      else {
        return (isset($element['#default_value']) && is_array($element['#default_value'])) ? $element['#default_value'] : array();
      }
    }
    // Non-multiple select elements may have an empty option preprended to them
    // (see form_process_select()). When this occurs, usually #empty_value is
    // an empty string, but some forms set #empty_value to integer 0 or some
    // other non-string constant. PHP receives all submitted form input as
    // strings, but if the empty option is selected, set the value to match the
    // empty value exactly.
    elseif (isset($element['#empty_value']) && $input === (string) $element['#empty_value']) {
      return $element['#empty_value'];
    }
    else {
      return $input;
    }
  }
}

I will work on a patch tomorrow.

CommentFileSizeAuthor
#2 submitting_an_empty-2742981-2.patch440 bytesdaften
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

daften created an issue. See original summary.

daften’s picture

Patch in attachment

daften’s picture

Status: Active » Needs review

Setting to needs review

cosolom’s picture

Status: Needs review » Reviewed & tested by the community

Worked for me in FAPI mode. Thanks.