You are here

function andromeda_slideshow_image_form in Andromeda Slideshow 7

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

Add and edit image form

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

File

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

Code

function andromeda_slideshow_image_form($form, &$form_state, $slideshow = NULL, $image = NULL) {
  $form = array(
    '#slideshow' => isset($slideshow) ? $slideshow : andromeda_slideshow_new_slideshow(),
    '#image' => isset($image) ? $image : andromeda_slideshow_new_image(),
  );
  $form['title'] = array(
    '#title' => t('Title'),
    '#description' => t('The title of the image'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#default_value' => !empty($image->title) ? $image->title : '',
    '#attributes' => array(
      'class' => array(
        'image-title',
      ),
    ),
  );
  $form['alt'] = array(
    '#title' => t('Alt'),
    '#description' => t('The alt attribute for the image.'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#default_value' => !empty($image->settings['alt']) ? $image->settings['alt'] : '',
    '#attributes' => array(
      'class' => array(
        'image-alt',
      ),
    ),
  );
  $form['fid'] = array(
    '#title' => t('Image'),
    '#type' => 'managed_file',
    '#default_value' => !empty($image->fid) ? $image->fid : '',
    '#required' => TRUE,
    '#upload_validators' => array(
      'file_validate_extensions' => array(
        'png jpg gif',
      ),
    ),
    '#upload_location' => 'public://slideshow/images/',
  );
  $form['caption'] = array(
    '#title' => t('Caption'),
    '#description' => t('The image caption to use for this image.'),
    '#type' => 'textarea',
    '#default_value' => !empty($image->caption) ? $image->caption : '',
    '#attributes' => array(
      'class' => array(
        'image-caption',
      ),
    ),
  );
  $form['link'] = array(
    '#title' => t('Link'),
    '#description' => t('Link for the image'),
    '#type' => 'textfield',
    '#default_value' => !empty($image->settings['link']) ? $image->settings['link'] : '',
    '#attributes' => array(
      'class' => array(
        'image-link',
      ),
    ),
  );
  $form['actions'] = array();
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $form['actions']['cancel'] = array(
    '#markup' => l(t('Cancel'), 'admin/structure/slideshows/manage/' . $slideshow->sid),
  );
  return $form;
}