/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $settings = $this->options; // Get the active field options. $options = $this->confGetFieldSources(); $missing_field_warning = ''; if (empty($options['field_options_images'])) { $missing_field_warning = t('<strong>You must add a field of type image, file or file ID to your view display before this value can be set.</strong><br/>'); } // Add the view-specific elements. $form['image_field'] = array('#type' => 'select', '#title' => t('Image Source'), '#default_value' => $settings['image_field'], '#description' => t('The field source to use for each image in the gallery. Must be an image field, file field or a file ID. If using a multivalued field (*) only the <em>first</em> value from each entity will be used.'), '#suffix' => $missing_field_warning, '#options' => $options['field_options_images'], '#empty_option' => t('- Select -')); $form['thumb_field'] = array('#type' => 'select', '#title' => t('Thumbnail Source'), '#default_value' => $settings['thumb_field'], '#description' => t('The field source to use for each thumbnail in the gallery. Must be an image field, file field or a file ID. Typically you will choose the same value that was set in the "Image Source" option above.'), '#suffix' => $missing_field_warning, '#options' => $options['field_options_images'], '#empty_option' => t('- Select -')); $form['image_field_style'] = array('#type' => 'select', '#title' => t('Image Field Style'), '#default_value' => $settings['image_field_style'], '#description' => t('The style formatter for the image. Any formatting settings configured on the field itself will be ignored and this style setting will always be used.'), '#options' => $this->juicebox->confBaseStylePresets(), '#empty_option' => t('None (original image)')); $form['thumb_field_style'] = array('#type' => 'select', '#title' => t('Thumbnail Field Style'), '#default_value' => $settings['thumb_field_style'], '#description' => t('The style formatter for the thumbnail. Any formatting settings configured on the field itself will be ignored and this style setting will always be used.'), '#options' => $this->juicebox->confBaseStylePresets(FALSE), '#empty_option' => t('None (original image)')); $form['title_field'] = array('#type' => 'select', '#title' => t('Title Field'), '#default_value' => $settings['title_field'], '#description' => t('The view\'s field that should be used for the title of each image in the gallery. Any formatting settings configured on the field itself will be respected.'), '#options' => $options['field_options'], '#empty_option' => t('None')); $form['caption_field'] = array('#type' => 'select', '#title' => t('Caption Field'), '#default_value' => $settings['caption_field'], '#description' => t('The view\'s field that should be used for the caption of each image in the gallery. Any formatting settings configured on the field itself will be respected.'), '#options' => $options['field_options'], '#empty_option' => t('None')); $form['show_title'] = array('#type' => 'checkbox', '#title' => t('Show Gallery Title'), '#default_value' => $settings['show_title'], '#description' => t('Show the view display title as the gallery title.')); // Add the common form elements. $form = $this->juicebox->confBaseForm($form, $settings); // Add view-sepcific field options for the linkURL setting. $linkurl_field_options = array(); foreach ($options['field_options'] as $field_key => $field_name) { $linkurl_field_options[$field_key] = t('Field') . ' - ' . $field_name; } $form['linkurl_source']['#description'] = $form['linkurl_source']['#description'] . '</br><strong>' . t('If using a field source it must render a properly formatted URL and nothing else.') . '</strong>'; $form['linkurl_source']['#options'] = array_merge($form['linkurl_source']['#options'], $linkurl_field_options); }
/** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { // Detect if this is a "pseudo" instance such that the field's context is // managed by something other than the core Field API (e.g., a fake instance // used for a a view row). This case is supported but we still want to put // up a notice about it. if ($this->isPseudoInstance()) { $element['instance_warning'] = array('#prefix' => '<div class="messages messages--warning">', '#markup' => t('<strong>WARNING:</strong> You appear to be using the Juicebox field formatter with a field instance that is not directly attached to an entity. Support for this configuration is currently experimental. Please test your final gallery output thoroughly.'), '#suffix' => '</div>'); } // Get available title and caption sources. $text_sources = $this->getFieldTextSources(); // Add the field-formatter-specific elements. $element['image_style'] = array('#type' => 'select', '#title' => t('Main Image Style'), '#default_value' => $this->getSetting('image_style'), '#description' => t('The style formatter for the main image.'), '#options' => $this->juicebox->confBaseStylePresets(), '#empty_option' => t('None (original image)')); $element['thumb_style'] = array('#type' => 'select', '#title' => t('Thumbnail Style'), '#default_value' => $this->getSetting('thumb_style'), '#description' => t('The style formatter for the thumbnail.'), '#options' => $this->juicebox->confBaseStylePresets(FALSE), '#empty_option' => t('None (original image)')); $element['caption_source'] = array('#type' => 'select', '#title' => t('Caption Source'), '#default_value' => $this->getSetting('caption_source'), '#description' => t('The image value that should be used for the caption.'), '#options' => $text_sources, '#empty_option' => t('No caption')); $element['title_source'] = array('#type' => 'select', '#title' => t('Title Source'), '#default_value' => $this->getSetting('title_source'), '#description' => t('The image value that should be used for the title.'), '#options' => $text_sources, '#empty_option' => t('No title')); // Add the common configuration options. $element = $this->juicebox->confBaseForm($element, $this->getSettings()); return $element; }