You are here

function royalsliderfield_field_widget_form in RoyalSlider Integration 7

Implements hook_field_widget_form().

File

contrib/royalsliderfield/royalsliderfield.module, line 153
RoyalSlider Field module.

Code

function royalsliderfield_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $required = $instance['required'] && $delta == 0 ? 1 : 0;
  $required_field = isset($instance['settings']['required_field']) ? $instance['settings']['required_field'] : 'rs_image';
  $element['rs_image'] = array(
    '#title' => t('Image'),
    '#description' => t('Allowed extensions: gif png jpg jpeg'),
    '#type' => 'managed_file',
    '#required' => $required && $required_field == 'rs_image' ? TRUE : FALSE,
    '#default_value' => isset($items[$delta]['rs_image']) ? $items[$delta]['rs_image'] : '',
    '#upload_location' => 'public://royalslider_images',
    '#upload_validators' => array(
      'file_validate_extensions' => array(
        'gif png jpg jpeg',
      ),
    ),
  );
  $element['rs_caption'] = array(
    '#title' => t('Image Caption'),
    '#description' => t('Image description.'),
    '#type' => 'textfield',
    '#required' => FALSE,
    '#default_value' => isset($items[$delta]['rs_caption']) ? $items[$delta]['rs_caption'] : '',
  );
  $element['rs_video'] = array(
    '#title' => t('Video URL'),
    '#description' => t('Add a Vimeo or YouTube video URL.'),
    '#type' => 'textfield',
    '#required' => FALSE,
    '#default_value' => isset($items[$delta]['rs_video']) ? $items[$delta]['rs_video'] : '',
  );
  $element['rs_content'] = array(
    '#type' => 'text_format',
    '#base_type' => 'textarea',
    '#title' => t('HTML Content'),
    '#format' => isset($items[$delta]['format']) ? $items[$delta]['format'] : filter_default_format(),
    '#required' => $required && $required_field == 'rs_content' ? TRUE : FALSE,
    '#default_value' => isset($items[$delta]['rs_content']) ? $items[$delta]['rs_content'] : NULL,
  );
  $element['rs_link'] = array(
    '#title' => t('Link'),
    '#description' => t('This will add an onclick attribute on the slide.'),
    '#type' => 'textfield',
    '#required' => FALSE,
    '#default_value' => isset($items[$delta]['rs_link']) ? $items[$delta]['rs_link'] : '',
  );
  return $element;
}