You are here

function nodereference_select_process in Content Construction Kit (CCK) 6.3

Same name and namespace in other branches
  1. 6 modules/nodereference/nodereference.module \nodereference_select_process()
  2. 6.2 modules/nodereference/nodereference.module \nodereference_select_process()

Process an individual element.

Build the form element. When creating a form using FAPI #process, note that $element['#value'] is already set.

The $fields array is in $form['#field_info'][$element['#field_name']].

1 string reference to 'nodereference_select_process'
nodereference_elements in modules/nodereference/nodereference.module
Implementation of FAPI hook_elements().

File

modules/nodereference/nodereference.module, line 588
Defines a field type for referencing one node from another.

Code

function nodereference_select_process($element, $edit, $form_state, $form) {

  // The nodereference_select widget doesn't need to create its own
  // element, it can wrap around the optionwidgets_select element.
  // This will create a new, nested instance of the field.
  // Add a validation step where the value can be unwrapped.
  $field_key = $element['#columns'][0];
  $element[$field_key] = array(
    '#type' => 'optionwidgets_select',
    '#default_value' => isset($element['#value']) ? $element['#value'] : '',
    // The following values were set by the content module and need
    // to be passed down to the nested element.
    '#title' => $element['#title'],
    '#required' => $element['#required'],
    '#description' => $element['#description'],
    '#field_name' => $element['#field_name'],
    '#type_name' => $element['#type_name'],
    '#delta' => $element['#delta'],
    '#columns' => $element['#columns'],
  );
  if (empty($element[$field_key]['#element_validate'])) {
    $element[$field_key]['#element_validate'] = array();
  }
  array_unshift($element[$field_key]['#element_validate'], 'nodereference_optionwidgets_validate');
  return $element;
}