You are here

function ad_ui_form in Advertisement 7.2

Form callback: create or edit an ad.

1 string reference to 'ad_ui_form'
ad_ui_menu in ./ad_ui.module
Implements hook_menu().

File

includes/ad_ui.inc, line 51

Code

function ad_ui_form($form, &$form_state, $ad) {
  $form = array();

  // Add the default field elements.
  // TODO: Update description to include the acceptable ad tokens.
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $ad->title,
    '#maxlength' => 255,
    '#required' => TRUE,
    '#weight' => -5,
  );

  // Add the field related form elements.
  $form_state['ad'] = $ad;
  field_attach_form('ad', $ad, $form, $form_state);
  $form['status'] = array(
    '#type' => 'radios',
    '#title' => t('Status'),
    '#description' => t('TODO.'),
    '#options' => array(
      '1' => t('Active'),
      '0' => t('Disabled'),
    ),
    '#default_value' => $ad->status,
    '#required' => TRUE,
    '#weight' => 35,
  );
  $form['actions'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'form-actions',
      ),
    ),
    '#weight' => 40,
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save advertisement'),
  );

  // Add the save and continue button for new ads.
  if (empty($ad->aid)) {
    $form['actions']['save_continue'] = array(
      '#type' => 'submit',
      '#value' => t('Save and add another'),
      '#suffix' => l('Cancel', 'admin/ad'),
      '#weight' => 45,
    );
  }
  else {
    $form['actions']['submit']['#suffix'] = l('Cancel', 'admin/ad');
  }
  return $form;
}