You are here

function flexslider_form_optionset_edit in Flex Slider 7

Same name and namespace in other branches
  1. 7.2 flexslider.admin.inc \flexslider_form_optionset_edit()

Form builder; Form to edit a given option set.

1 string reference to 'flexslider_form_optionset_edit'
flexslider_menu in ./flexslider.module
Implements hook_menu().

File

./flexslider.admin.inc, line 270
Administrative page callbacks for the flexslider module.

Code

function flexslider_form_optionset_edit($form, &$form_state, $optionset) {
  if (empty($form_state['optionset'])) {
    $form_state['optionset'] = $optionset;
  }
  else {
    $optionset = $form_state['optionset'];
  }

  // Title
  $form['title'] = array(
    '#type' => 'textfield',
    '#maxlength' => '255',
    '#title' => t('Title'),
    '#default_value' => $optionset->title,
    '#description' => t('A human-readable title for this option set.'),
    '#required' => TRUE,
  );

  // Show select boxes for the various image styles (thumbnail, normal, big)
  $image_style = image_style_options(FALSE);
  $form['image_style'] = array(
    '#type' => 'fieldset',
    '#title' => 'Image style',
    '#tree' => TRUE,
  );
  $form['image_style']['normal'] = array(
    '#type' => 'select',
    '#title' => t('Normal image style'),
    '#description' => t('Image style for the main stage images.'),
    '#empty_option' => t('None (original image)'),
    '#options' => $image_style,
    '#default_value' => $optionset->imagestyle_normal,
  );

  // Options Vertical Tab Group table
  $form['options'] = array(
    '#type' => 'vertical_tabs',
  );
  $default_options = flexslider_option_elements($optionset->options);

  // Add the options to the vertical tabs section
  foreach ($default_options as $key => $value) {
    $form['options'][] = $value;
  }

  // Add form actions
  $form['actions'] = array(
    '#type' => 'actions',
    'submit' => array(
      '#type' => 'submit',
      '#name' => 'submit',
      '#value' => t('Save option set'),
    ),
    'cancel' => array(
      '#type' => 'link',
      '#title' => t('Cancel'),
      '#href' => 'admin/config/media/flexslider',
    ),
  );
  return $form;
}