function entityconnect_child_form_alter in Entity connect 7.2
Same name and namespace in other branches
- 7 includes/entityconnect.form.inc \entityconnect_child_form_alter()
Alters child create form.
We add a value field to hold the parent build_cache_id then we add a cancel button that run entityconnect_child_form_cancel and a new submit button.
1 call to entityconnect_child_form_alter()
- entityconnect_form_alter in ./
entityconnect.module - Implements hook_form_alter().
File
- includes/
entityconnect.form.inc, line 792 - Handles all form alters and submit functions for entityconnect.
Code
function entityconnect_child_form_alter(&$form, &$form_state, $form_id, $cache_id, $cache) {
// Exclude some forms to be processed.
$exclude_forms = array(
'search_block_form',
);
// Allow other modules to alter exclude forms list.
drupal_alter('entityconnect_exclude_forms', $exclude_forms);
if (in_array($form_id, $exclude_forms)) {
return;
}
$form['parent_build_cache_id'] = array(
'#type' => 'value',
'#value' => $cache_id,
);
$form['actions']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#submit' => array(
'entityconnect_include_form',
'entityconnect_child_form_cancel',
),
'#parent_build_cache_id' => $cache_id,
'#limit_validation_errors' => array(),
'#weight' => 1000,
);
switch ($form_id) {
case 'user_register_form':
$form['actions']['submit']['#submit'][] = 'user_register_submit';
break;
case 'user_profile_form':
$form['actions']['submit']['#submit'][] = 'user_profile_form_submit';
break;
case 'taxonomy_form_term':
$form['actions']['submit']['#submit'][] = 'taxonomy_form_term_submit';
break;
case 'taxonomy_form_vocabulary':
$form['actions']['submit']['#submit'][] = 'taxonomy_form_vocabulary_submit';
break;
case 'node_delete_confirm':
$form['actions']['submit']['#submit'] = $form['#submit'];
$form['#submit'] = array();
break;
default:
break;
}
if (isset($form['submit']['#submit'])) {
$form['submit']['#submit'][] = 'entityconnect_include_form';
$form['submit']['#submit'][] = 'entityconnect_child_form_submit';
}
else {
$form['actions']['submit']['#submit'][] = 'entityconnect_include_form';
$form['actions']['submit']['#submit'][] = 'entityconnect_child_form_submit';
}
if (strpos($form_id, '_delete_confirm') === false) {
$form['actions']['delete']['#submit'][] = 'entityconnect_include_form';
$form['actions']['delete']['#submit'][] = 'entityconnect_child_form_delete_submit';
}
$datas = array(
'form' => &$form,
'form_state' => &$form_state,
'form_id' => $form_id,
);
drupal_alter('entityconnect_child_form', $datas);
}