You are here

function relation_add_widget_ajax in Relation add 7

AJAX callback for widget form.

1 string reference to 'relation_add_widget_ajax'
relation_add_field_widget_form in ./relation_add.module
Implements hook_field_widget_form().

File

./relation_add.module, line 913
Relation Add module file.

Code

function relation_add_widget_ajax($form, $form_state) {
  $path = $form_state['triggering_element']['#parents'];
  $field_name = array_shift($path);
  $language = array_shift($path);
  $item = array_shift($path);
  $type = array_shift($path);
  switch ($type) {
    case 'relation_type':
      return $form[$field_name][$language][$item]['relation_options'];
    case 'relation_options':
      if (!empty($path)) {
        $button = array_shift($path);
        if ('targets_add' == $button) {
          return $form[$field_name][$language][$item]['relation_options']['targets'];
        }
      }
      break;
  }
}