function optionwidgets_form2data in Content Construction Kit (CCK) 6.2
Same name and namespace in other branches
- 6.3 modules/optionwidgets/optionwidgets.module \optionwidgets_form2data()
- 6 modules/optionwidgets/optionwidgets.module \optionwidgets_form2data()
Helper function to transpose the values returned by submitting the widget to the format to be stored in the field. Can be called anywhere this transformation is needed.
1 call to optionwidgets_form2data()
- optionwidgets_validate in modules/
optionwidgets/ optionwidgets.module - FAPI function to validate optionwidgets element.
File
- modules/
optionwidgets/ optionwidgets.module, line 368 - Defines selection, check box and radio button widgets for text and numeric fields.
Code
function optionwidgets_form2data($element, $field) {
$field_key = $element['#columns'][0];
$items = (array) $element[$field_key]['#value'];
$options = optionwidgets_options($field);
$values = array_values($items);
if ($element['#type'] == 'optionwidgets_onoff' && $values[0] === 0) {
$keys = array_keys($options);
$values = array(
array_key_exists(0, $keys) ? $keys[0] : NULL,
);
}
if (empty($values)) {
$values[] = NULL;
}
$result = content_transpose_array_rows_cols(array(
$field_key => $values,
));
return $result;
}