You are here

function andromeda_slideshow_form in Andromeda Slideshow 7

Same name and namespace in other branches
  1. 7.2 includes/andromeda_slideshow.forms.inc \andromeda_slideshow_form()

Add and edit slideshow form

1 string reference to 'andromeda_slideshow_form'
andromeda_slideshow_menu in ./andromeda_slideshow.module
Implements hook_menu().

File

includes/andromeda_slideshow.forms.inc, line 11
Form definitions for andromeda slideshow module

Code

function andromeda_slideshow_form($form, &$form_state, $slideshow = NULL) {

  //load helper functions
  ctools_include('andromeda_slideshow', 'andromeda_slideshow');
  $form = array(
    '#slideshow' => isset($slideshow) ? $slideshow : andromeda_slideshow_new_slideshow(),
  );
  $form['title'] = array(
    '#title' => t('Title'),
    '#description' => t('Example: Front page slideshow'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#default_value' => !empty($slideshow->title) ? $slideshow->title : '',
    '#attributes' => array(
      'class' => array(
        'slideshow-title',
      ),
    ),
  );
  $form['name'] = array(
    '#type' => 'machine_name',
    '#title' => t('Machine-readable name'),
    '#machine_name' => array(
      'exists' => 'andromeda_slideshow_machine_name_exists',
      'source' => array(
        'title',
      ),
    ),
    '#description' => t('Example: front_page_slideshow') . '<br/>' . t('May only contain lowercase letters, numbers and underscores.'),
    '#required' => TRUE,
    '#default_value' => !empty($slideshow->name) ? $slideshow->name : '',
    '#attributes' => array(
      'class' => array(
        'slideshow-name',
      ),
    ),
  );
  $form['description'] = array(
    '#title' => t('Description'),
    '#description' => t('A description for this slideshow'),
    '#type' => 'textfield',
    '#default_value' => !empty($slideshow->description) ? $slideshow->description : '',
    '#attributes' => array(
      'class' => array(
        'slideshow-description',
      ),
    ),
  );
  $form['image_style'] = array(
    '#type' => 'select',
    '#title' => t('Image style'),
    '#options' => andromeda_slideshow_get_image_styles(),
    '#required' => TRUE,
    '#default_value' => !empty($slideshow->settings['image_style']) ? $slideshow->settings['image_style'] : '',
  );

  //add slideshow types
  $types = array();
  $types['default'] = t('Default');
  foreach (andromeda_slideshow_get_types() as $key => $type) {
    $types[$key] = $type['name'];
  }
  $form['type'] = array(
    '#type' => 'select',
    '#title' => t('Type'),
    '#options' => $types,
    '#required' => TRUE,
    '#default_value' => !empty($slideshow->settings['type']) ? $slideshow->settings['type'] : '',
  );
  $form['status'] = array(
    '#type' => 'radios',
    '#title' => t('Status'),
    '#options' => array(
      1 => t('Enabled'),
      0 => t('Disabled'),
    ),
    '#required' => TRUE,
    '#default_value' => isset($slideshow->settings['status']) ? $slideshow->settings['status'] : 1,
  );
  $form['actions'] = array();
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $form['actions']['cancel'] = array(
    '#markup' => l(t('Cancel'), 'admin/structure/slideshows'),
  );
  return $form;
}