function rolereference_optionwidgets_validate in Role Reference 6
Validate a select/buttons element.
Remove the wrapper layer and set the right element's value. We don't know exactly where this element is, so we drill down through the element until we get to our key.
We use $form_state['values'] instead of $element['#value'] to be sure we have the most accurate value when other modules like optionwidgets are using #element_validate to alter the value.
2 string references to 'rolereference_optionwidgets_validate'
- rolereference_buttons_process in ./
rolereference.module - Process an individual element.
- rolereference_select_process in ./
rolereference.module - Process an individual element.
File
- ./
rolereference.module, line 576 - Defines a field type for referencing a role. Based almost entirely on nodereference and userreference modules.
Code
function rolereference_optionwidgets_validate($element, &$form_state) {
$field_key = $element['#columns'][0];
$value = $form_state['values'];
$new_parents = array();
foreach ($element['#parents'] as $parent) {
$value = $value[$parent];
// Use === to be sure we get right results if parent is a zero (delta) value.
if ($parent === $field_key) {
$element['#parents'] = $new_parents;
form_set_value($element, $value, $form_state);
break;
}
$new_parents[] = $parent;
}
}