You are here

function rotor_form in Rotor Banner 5.7

Same name and namespace in other branches
  1. 5 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 166
A rotor banner consists in a set of images that will be changing. This module is made using jquery.

Code

function rotor_form($node) {

  // Get metadata
  $type = node_get_types('type', $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('image', file_create_url($node->rotor_image), '', '', NULL, FALSE) : '';
  $form['rotor_image'] = array(
    '#type' => 'file',
    '#title' => t('Attach an image'),
    '#default_value' => $node->rotor_image,
    '#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['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;
}