You are here

function entityconnect_child_form_submit in Entity connect 7

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

Sets submit button on child create form.

On submission of a child form we set: the target_id in the cache entry the redirect to our redirect page.

1 string reference to 'entityconnect_child_form_submit'
entityconnect_child_form_alter in includes/entityconnect.form.inc
Alters child create form.

File

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

Code

function entityconnect_child_form_submit(&$form, &$form_state) {
  $cache_id = $form_state['values']['parent_build_cache_id'];
  if ($cache_id && ($cache = entityconnect_cache_get($cache_id))) {
    $data = $cache->data;
    $entity_type = $cache->data['target_entity_type'];
    switch ($entity_type) {
      case 'node':
        $data['target_id'] = $form_state['values']['nid'];
        break;
      case 'user':
        $data['target_id'] = $form_state['values']['name'];
        break;
      case 'taxonomy_term':
        $data['target_id'] = $form_state['values']['tid'];
        break;
      case 'taxonomy_vocabulary':
        $data['target_id'] = $form_state['values']['vid'];
        break;
      default:

        // Entity construction kit support.
        if (module_exists('eck')) {
          $entity_info = entity_get_info($entity_type);
          if ($entity_info['module'] == 'eck') {
            $data['target_id'] = $form_state['values']['entity']->id;
          }
        }

        // Bean support.
        if (module_exists('bean_admin_ui')) {
          $entity_info = entity_get_info($entity_type);
          if ($entity_info['module'] == 'bean') {
            $data['target_id'] = $form_state['values']['bean']->bid;
          }
        }
        break;
    }
    entityconnect_cache_set($cache_id, $data);
    $form_state['redirect'] = "admin/entityconnect/return/{$cache_id}";
  }
}