You are here

function blockreference_select_validate in Block reference 6

Validate an select 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.

1 string reference to 'blockreference_select_validate'
blockreference_select_process in ./blockreference.module
Process an individual element.

File

./blockreference.module, line 595
Defines a field type for referencing a block from a node.

Code

function blockreference_select_validate($element, &$form_state) {
  $field_key = $element['#columns'][0];
  $new_parents = array();
  $value = $form_state['values'];
  foreach ($element['#parents'] as $parent) {
    $value = $value[$parent];
    if ($parent == $field_key) {
      $element['#parents'] = $new_parents;
      form_set_value($element, $value, $form_state);
      break;
    }
    $new_parents[] = $parent;
  }
}