You are here

function addanother_form_alter in Add Another 7.2

Same name and namespace in other branches
  1. 5 addanother.module \addanother_form_alter()
  2. 6 addanother.module \addanother_form_alter()

Implements hook_form_alter().

File

./addanother.module, line 178
The main file for the addanother module.

Code

function addanother_form_alter(&$form, $form_state, $form_id) {
  if (!empty($form['#node_edit_form']) && empty($form['nid']['#value'])) {
    $node_type = $form['type']['#value'];
    if (user_access('use add another')) {
      if (variable_get('addanother_button_' . $node_type, FALSE)) {
        $form['actions']['addanother'] = array(
          '#type' => 'submit',
          '#value' => t('Save and add another'),
          '#weight' => -41,
          '#submit' => array(
            'node_form_submit',
            'addanother_node_form_submit',
          ),
        );
      }
      if (variable_get('addanother_message_' . $node_type, FALSE)) {
        $form['actions']['submit']['#submit'][] = 'addanother_node_form_message_submit';
      }
    }
  }
}