function node_recur_form_alter in Node recur 7
Implements hook_form_alter().
File
- ./
node_recur.module, line 48  
Code
function node_recur_form_alter(&$form, &$form_state, $form_id) {
  // See if this is a node form
  if (isset($form['#node_edit_form']) && $form['#node_edit_form']) {
    // See if this is an 'add' operation
    if (!$form['nid']['#value'] && !$form_state['executed']) {
      // Check permissions
      if (node_recur_node_recur_form_access($form['#node'])) {
        // See if we should display options for this node type
        if (node_recur_node_form_enabled($form['#node']->type)) {
          // Make sure recurring is enabled for this node
          if (node_recur_recurring_enabled($form['#node']->type)) {
            module_load_include('inc', 'node_recur', 'node_recur.pages');
            // Get the date field name
            $date_field = node_recur_get_date_field_name($form['#node']->type);
            // Get the recur form
            $recur_form = _node_recur_node_recur_form($form['#node']->type);
            // Change the default option
            $recur_form['option']['#default_value'] = 'none';
            // Set the until date to not be required
            $recur_form['until']['#required'] = FALSE;
            // Add fieldset wrapper
            $form['node_recur'] = array(
              '#type' => 'fieldset',
              '#title' => t('Repeat'),
              '#weight' => $form[$date_field]['#weight'] + 0.1,
            );
            // Merge the form into the wrapper
            $form['node_recur'] = array_merge($form['node_recur'], $recur_form);
            // Add validation and submission
            $form['#validate'][] = 'node_recur_node_form_validate';
            $form['actions']['submit']['#submit'][] = 'node_recur_node_form_submit';
          }
        }
      }
    }
  }
}