function _options_form_to_storage
_options_form_to_storage($element)
Transforms submitted form values into field storage format.
File
- modules/field/modules/options/options.module, line 311
- Defines selection, check box and radio button widgets for text and numeric fields.
Code
function _options_form_to_storage($element) { $values = array_values((array) $element['#value']); $properties = $element['#properties']; // On/off checkbox: transform '0 / 1' into the 'on / off' values. if ($element['#type'] == 'checkbox') { $values = array($values[0] ? $element['#on_value'] : $element['#off_value']); } // Filter out the 'none' option. Use a strict comparison, because // 0 == 'any string'. if ($properties['empty_option']) { $index = array_search('_none', $values, TRUE); if ($index !== FALSE) { unset($values[$index]); } } // Make sure we populate at least an empty value. if (empty($values)) { $values = array(NULL); } $result = options_array_transpose(array($element['#value_key'] => $values)); return $result; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field!modules!options!options.module/function/_options_form_to_storage/7.x