You are here

function _entityconnect_alter_form_state_input in Entity connect 7.2

Same name and namespace in other branches
  1. 7 includes/entityconnect.form.inc \_entityconnect_alter_form_state_input()

Used to update the form state value.

Form state value is updated for entityreference, node_reference or user_reference field after adding a new entity.

Parameters

array $form_state: The form_state we need to change.

string $module: As entityconnect deals with 3 different modules, we need to know which one is used.

string $widget_type: The type of the widget used for reference field.

array $parents: The array of all parents of the field. We used them to change the value to the right level in the array.

string $language: The language of the field.

array $element: The value we need to insert.

1 call to _entityconnect_alter_form_state_input()
entityconnect_return_form_alter in includes/entityconnect.form.inc
Complete entityreference field on parent form with the target_id value.

File

includes/entityconnect.form.inc, line 886
Handles all form alters and submit functions for entityconnect.

Code

function _entityconnect_alter_form_state_input(&$form_state, $module, $widget_type, $parents, $language, $element) {
  switch ($widget_type) {
    case 'autocomplete':
    case 'multiple_selects':
      switch ($module) {
        case 'entityreference':
          array_push($parents, "target_id");
          break;
        case 'node_reference':
          array_push($parents, "nid");
          break;
        case 'user_reference':
          array_push($parents, "uid");
          break;
      }
      break;
    case 'textfield':
    case 'select':
    case 'radios':
    case 'checkboxes':
      array_push($parents, $language);
      break;
    default:
      break;
  }
  entityconnect_array_set_nested_value($form_state['input'], $parents, $element);
}