/** * Builds the flexslider settings form. * * @param \Drupal\Core\Field\FormatterBase $formatter * @param array $formatter_settings * * @return array */ protected function buildSettingsForm(FormatterBase $formatter) { // Get list of option sets as an associative array. $optionsets = flexslider_optionset_list(); $element['optionset'] = array('#title' => $formatter->t('Option Set'), '#type' => 'select', '#default_value' => $formatter->getSetting('optionset'), '#options' => $optionsets); $element['links'] = array('#theme' => 'links', '#links' => array(array('title' => $formatter->t('Create new option set'), 'url' => Url::fromRoute('entity.flexslider.add_form', array(), array('query' => \Drupal::destination()->getAsArray()))), array('title' => $formatter->t('Manage option sets'), 'url' => Url::fromRoute('entity.flexslider.collection', array(), array('query' => \Drupal::destination()->getAsArray())))), '#access' => \Drupal::currentUser()->hasPermission('administer flexslider')); return $element; }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['flexslider'] = array('#type' => 'fieldset', '#title' => $this->t('FlexSlider')); $form['flexslider']['optionset'] = array('#title' => t('Option set'), '#type' => 'select', '#options' => flexslider_optionset_list(), '#default_value' => $this->options['optionset']); $captionfield_options = array('' => $this->t('None')); foreach ($this->displayHandler->getHandlers('field') as $field => $handler) { $captionfield_options[$field] = $handler->adminLabel(); } $form['flexslider']['captionfield'] = array('#type' => 'select', '#title' => $this->t('Caption Field'), '#description' => $this->t("Select a field to be used as the caption. This can also be set manually by adding the '.flex-caption' class to a field. Required to use thumbnail captions."), '#options' => $captionfield_options, '#default_value' => $this->options['captionfield']); $form['flexslider']['id'] = array('#type' => 'textfield', '#title' => $this->t('Element ID'), '#description' => $this->t("Manually define the FlexSlider container ID attribute <em>Ensure you don't display similar ID elements on the same page</em>."), '#size' => 40, '#maxlength' => 255, '#default_value' => $this->options['id']); }