You are here

function entityconnect_child_form_submit in Entity connect 7.2

Same name and namespace in other branches
  1. 7 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 449
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:
        $datas = array(
          'form' => &$form,
          'form_state' => &$form_state,
          'entity_type' => $entity_type,
          'data' => &$data,
        );
        drupal_alter('entityconnect_child_form_submit', $datas);
        break;
    }
    entityconnect_cache_set($cache_id, $data);
    $form_state['redirect'] = "admin/entityconnect/return/{$cache_id}";
  }
}