You are here

function oa_core_select2widget_entity_validate_field in Open Atrium Core 7.2

Validate the entities as real, including custom all/current.

1 call to oa_core_select2widget_entity_validate_field()
oa_core_adjust_og_group_ref_for_select2 in ./oa_core.module
Adjust element so select2 works.
2 string references to 'oa_core_select2widget_entity_validate_field'
oa_core_og_group_ref_process in includes/oa_core.fields.inc
Process function of the og_group_ref field.
oa_core_og_group_ref_views_handler_filter_entityreference_autocomplete::value_form in plugins/views/oa_core_og_group_ref_views_handler_filter_entityreference_autocomplete.inc

File

includes/oa_core.fields.inc, line 95
Code for custom Form API fields in Open Atrium

Code

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

  // Legacy support, empty means current.
  if (!empty($element['#convert_empty_to_current']) && empty($element['#value'])) {

    // If filter is on an admin view or user view, default to show All spaces
    if (isset($form_state['view']->tag) && $form_state['view']->tag == 'admin' || isset($form_state['view']->argument['user'])) {
      $element['#value'] = _oa_core_select2widget_all_label();
    }
    else {
      $element['#value'] = OA_SPACE_CURRENT;
    }
  }
  if (empty($element['#oa_core_in_pane_config'])) {
    $element['#value'] = str_replace(OA_SPACE_CURRENT, oa_core_get_space_context(), $element['#value']);
    $element['#value'] = str_replace(_oa_core_select2widget_current_label(), oa_core_get_space_context(), $element['#value']);
  }
  $element['#value'] = str_replace(_oa_core_select2widget_all_label(), 'All', $element['#value']);
  $entity_labels = _oa_core_select2widget_process_entity_labels($element['#value']);
  $element['#attached']['js'][0]['data']['select2widgetajax']['elements'][$element['#id']]['init'] = $entity_labels;
  if (!empty($element['#oa_core_select2_set_value']) && $entity_labels && isset($form_state['values'])) {
    $value = array_keys($entity_labels);
    form_set_value($element, current($value), $form_state);
  }
}