You are here

function _node_reference_view_settings_validate in References 7.2

Validate callback for the 'view settings' fieldset.

Puts back the various form values in the expected shape.

1 string reference to '_node_reference_view_settings_validate'
node_reference_field_settings_form in node_reference/node_reference.module
Implements hook_field_settings_form().

File

node_reference/node_reference.module, line 131
Defines a field type for referencing one node from another.

Code

function _node_reference_view_settings_validate($element, &$form_state, $form) {

  // Split view name and display name from the 'view_and_display' value.
  if (!empty($element['view_and_display']['#value'])) {
    list($view, $display) = explode(':', $element['view_and_display']['#value']);
  }
  else {
    $view = '';
    $display = '';
  }

  // Explode the 'args' string into an actual array. Beware, explode() turns an
  // empty string into an array with one empty string. We'll need an empty array
  // instead.
  $args_string = trim($element['args']['#value']);
  $args = $args_string === '' ? array() : array_map('trim', explode(',', $args_string));
  $value = array(
    'view_name' => $view,
    'display_name' => $display,
    'args' => $args,
  );
  form_set_value($element, $value, $form_state);
}