0

Hi i'm trying to extend scheduler module forms. The one i need is included as fieldset in node as extra field refer to image enter image description here

/**
 *  Implements hook_form_node_type_form_alter(). 
 */

 function nodequeue_scheduler_form_node_type_form_alter(&$form, $form_state) {

    //This  node type configuration form with schedule options

    $form['scheduler']['nodequeue_sheduler'] = array(
      '#type' => 'fieldset',
      '#title' => t('Nodequeue Scheduler Settings'),
      '#collapsible' => FALSE,
      '#group' => 'scheduler',
      '#weight' => 10,
    );

   }

/**
 * Implements hook_form_FORM_ID_alter().
 */
function nodequeue_scheduler_form_scheduler_node_form_alter(&$form, $form_state) {

   //feldset or vertical tab for scheduler to ammend
$options = array (1,2,3);
// Adding few custom fields
$form['scheduler_settings']['publish_nodequeue'] = array(
 '#type' => 'fieldset',
 '#title' => t('Nodequeue Scheduling settings'),

);
$form['scheduler_settings'] ['publish_nodequeue']['schedule_nodequeue'] = array(
 '#type' => 'checkbox',
 '#default_value' => 1,
 '#title' => t('Add to nodequeue when published')
);

$form['scheduler_settings']['publish_nodequeue']['nodequeue_position'] = array(
 '#type' => 'select',
 '#options' => $options,
 '#title' => t('Position')

);
$form['scheduler_settings']['publish_nodequeue']['publish_on'] = array(
 '#type' => 'textfield',
 '#title' => t('Publish on'),
 '#maxlength' => 30,

);
// function scheduler_mail_form_scheduler_node_form_alter(&$form, $form_state) {
//    $email_enabled = variable_get('scheduler_mail_enable_' . $form['type']['#value'], 0);
//    if (!$email_enabled) {
//      return;
//    }

//    $node = $form['#node'];
//    $settings = _scheduler_mail_load($node);

//    $form['scheduler_settings']['scheduler_mail'] = array(
//      '#type' => 'fieldset',
//      '#title' => t('Email settings'),
//    );
//    $form['scheduler_settings']['scheduler_mail']['scheduler_mail_send'] = array(
//      '#type' => 'checkbox',
//      '#title' => t('Send an email notification when this node is (un)published'),
//      '#default_value' => $settings->send,
//    );
//    $form['scheduler_settings']['scheduler_mail']['scheduler_mail_address'] = array(
//      '#type' => 'textfield',
//      '#title' => t('Use this email address'),
//      '#description' => t('If left blank, email will go to the original author of this node'),
//      '#default_value' => $settings->address,
//      '#maxlength' => 255,
//      '#states' => array(
//        'visible' => array(
//          "input[name='scheduler_mail_send']" => array("checked" => true)
//        ),
//      ),
//    );
//    $form['#validate'][] = '_scheduler_mail_validate';
//    $form['#submit'][] = '_scheduler_mail_submit';
  }

I have found module scheduler mail and it alters the node type form and add some configuration fields as checkbox but not getting the form which is in node edit form . How do i do it in drupal 7

0

If scheduler is using hook_form_alter() on a form, and your module is also using hook_form_alter() on the same form, the order of execution of these two hook_form_alter() functions matters. Evidently, your module's hook_form_alter() is getting called before scheduler can add the new form elements you're trying to modify.

Drupal executes these hooks in order of module weight. If you do not set the module weight, then I believe they all default to the same value and hooks with the same weight will get called in alphabetical order (but this is not guaranteed).

To ensure that your module gets called after scheduler, you need to set your module's weight to be greater than the scheduler's module weight. This is how you do that in your module's install file:

/**
 * Implements hook_install().
 */
function my_module_install() {
  // Because we need to alter a form that is also altered by the scheduler
  // module, we need to ensure this module gets loaded AFTER the scheduler.
  $weight = db_query('SELECT weight FROM {system} WHERE name = :name', array(':name' => 'scheduler'))->fetchField();
  db_update('system')
    ->fields(array(
      'weight' => $weight + 1
    ))
    ->condition('name', 'my_module')
    ->execute();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.