You are here

function notifications_add_subscription_form in Notifications 6

Same name and namespace in other branches
  1. 6.2 notifications.pages.inc \notifications_add_subscription_form()
  2. 6.3 notifications.pages.inc \notifications_add_subscription_form()

Form for creating new subscriptions

1 string reference to 'notifications_add_subscription_form'
notifications_ui_page_user_add in notifications_ui/notifications_ui.pages.inc
User add subscription

File

./notifications.pages.inc, line 57
User pages for Notifications

Code

function notifications_add_subscription_form($form_state, $account, $type) {
  $info = notifications_subscription_types($type);
  $form['account'] = array(
    '#type' => 'value',
    '#value' => $account,
  );
  $form['type'] = array(
    '#type' => 'value',
    '#value' => $type,
  );

  // Display general information
  $form['info'] = array(
    '#type' => 'item',
    '#title' => t('Create @type subscription', array(
      '@type' => $info['title'],
    )),
    '#description' => !empty($info['description']) ? $info['description'] : '',
  );

  // Build subscription fields
  $form['fields']['#tree'] = TRUE;
  foreach ($info['fields'] as $fid => $field_type) {
    $field = notifications_subscription_fields($field_type);
    $form['fields'][$fid]['type'] = array(
      '#type' => 'value',
      '#value' => $field_type,
    );
    $form['fields'][$fid]['value'] = notifications_subscription_form_field($field_type);
    $form['fields'][$fid]['value'] += array(
      '#title' => $field['name'],
      '#required' => TRUE,
    );
  }
  $form['send_interval'] = array(
    '#type' => 'select',
    '#title' => t('Send interval'),
    '#options' => _notifications_send_intervals(),
    '#default_value' => $subscription->send_interval,
  );
  $send_methods = _notifications_send_methods();
  $form['send_method'] = array(
    '#type' => 'select',
    '#title' => t('Send method'),
    '#options' => $send_methods,
    '#default_value' => $subscription->send_method,
  );
  $form['buttons']['save'] = array(
    '#type' => 'submit',
    '#value' => t('Create subscription'),
  );
  $form['buttons']['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Cancel'),
  );
  return $form;
}