You are here

function rotor_form in Rotor Banner 5

Same name and namespace in other branches
  1. 5.7 rotor.module \rotor_form()
  2. 6.2 rotor.module \rotor_form()
  3. 6 rotor.module \rotor_form()
  4. 7 rotor.module \rotor_form()

Node form hook

File

./rotor.module, line 281
A rotor banner consists in a set of images that will be changing. This module is made using jquery.

Code

function rotor_form($node) {
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Tab Text'),
    '#required' => TRUE,
    '#default_value' => $node->title,
    '#weight' => -5,
    '#description' => t('The text that will be shown in the tab for this item.'),
  );
  $image = $node->rotor_image ? theme('rotor_image', $node) : '';
  $form['rotor_image'] = array(
    '#type' => 'file',
    '#title' => t('Attach an image'),
    '#default_value' => $node->rotor_image->filepath,
    '#weight' => -4,
    '#prefix' => $image,
    '#description' => t('The image that will be shown in the rotor content.' . ' If an image is uploaded only the image will be shown, otherwise only the content.'),
  );
  $form['alt_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Image Alt text'),
    '#default_value' => $node->rotor_image->alt_text,
    '#weight' => -3,
    '#description' => t('That alt text for the image. This will also be displayed when the mouse is vovered over the image.'),
  );
  $form['link'] = array(
    '#type' => 'fieldset',
    '#title' => t('Link'),
    '#attributes' => array(
      'class' => 'rotor-link',
    ),
    '#weight' => -2,
  );
  $form['link']['url'] = array(
    '#type' => 'textfield',
    '#title' => t('Link URL'),
    '#default_value' => $node->rotor_image->url,
    '#description' => t('The link that will be actived for this item. Example: http://www.drupal.org, node/3'),
  );
  $target_options = array(
    'default' => t('Default (no target attribute)'),
    '_top' => t('Open link in window root (_top)'),
    '_blank' => t('Open link in new window (_blank)'),
  );
  $form['link']['link_target'] = array(
    '#type' => 'select',
    '#title' => t('Link target'),
    '#options' => $target_options,
    '#default_value' => $node->rotor_image->link_target,
    '#description' => t('The target of the link'),
  );
  $form['body_filter']['body'] = array(
    '#type' => 'textarea',
    '#title' => t('Content'),
    '#default_value' => $node->body,
    '#rows' => 10,
    '#weight' => -3,
    '#description' => t('The content that will be shown in case no image is uploaded.'),
  );
  $form['body_filter']['filter'] = filter_form($node->format);

  // Change the enctype of the form to handle the upload file.
  $form['#attributes']['enctype'] = 'multipart/form-data';
  return $form;
}