Exemplo n.º 1
0
 /**
  * Render the given style.
  */
 public function buildOptionsForm(&$form, &$form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['type'] = array('#type' => 'radios', '#title' => t('List type'), '#options' => array('ul' => t('Unordered list'), 'ol' => t('Ordered list')), '#default_value' => $this->options['type']);
     $form['wrapper_class'] = array('#title' => t('Wrapper class'), '#description' => t('The class to provide on the wrapper, outside the list.'), '#type' => 'textfield', '#size' => '30', '#default_value' => $this->options['wrapper_class']);
     $form['class'] = array('#title' => t('List class'), '#description' => t('The class to provide on the list element itself.'), '#type' => 'textfield', '#size' => '30', '#default_value' => $this->options['class']);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, &$form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['columns'] = array('#type' => 'number', '#title' => t('Number of columns'), '#default_value' => $this->options['columns'], '#required' => TRUE, '#min' => 1);
     $form['automatic_width'] = array('#type' => 'checkbox', '#title' => t('Automatic width'), '#description' => t('The width of each column will be calculated automatically based on the number of columns provided. If additional classes are entered or a theme injects classes based on a grid system, disabling this option may prove beneficial.'), '#default_value' => $this->options['automatic_width']);
     $form['alignment'] = array('#type' => 'radios', '#title' => t('Alignment'), '#options' => array('horizontal' => t('Horizontal'), 'vertical' => t('Vertical')), '#default_value' => $this->options['alignment'], '#description' => t('Horizontal alignment will place items starting in the upper left and moving right. Vertical alignment will place items starting in the upper left and moving down.'));
     $form['col_class_default'] = array('#title' => t('Default column classes'), '#description' => t('Add the default views column classes like views-col, col-1 and clearfix to the output. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.'), '#type' => 'checkbox', '#default_value' => $this->options['col_class_default']);
     $form['col_class_custom'] = array('#title' => t('Custom column class'), '#description' => t('Additional classes to provide on each column. Separated by a space.'), '#type' => 'textfield', '#default_value' => $this->options['col_class_custom']);
     if ($this->usesFields()) {
         $form['col_class_custom']['#description'] .= ' ' . t('You may use field tokens from as per the "Replacement patterns" used in "Rewrite the output of this field" for all fields.');
     }
     $form['row_class_default'] = array('#title' => t('Default row classes'), '#description' => t('Adds the default views row classes like views-row, row-1 and clearfix to the output. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.'), '#type' => 'checkbox', '#default_value' => $this->options['row_class_default']);
     $form['row_class_custom'] = array('#title' => t('Custom row class'), '#description' => t('Additional classes to provide on each row. Separated by a space.'), '#type' => 'textfield', '#default_value' => $this->options['row_class_custom']);
     if ($this->usesFields()) {
         $form['row_class_custom']['#description'] .= ' ' . t('You may use field tokens from as per the "Replacement patterns" used in "Rewrite the output of this field" for all fields.');
     }
 }
Exemplo n.º 3
0
 /**
  * Overrides Drupal\views\Plugin\views\style\StylePluginBase::buildOptionsForm().
  */
 public function buildOptionsForm(&$form, &$form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     // Get the mapping.
     $mapping = $this->defineMapping();
     // Restrict the list of defaults to the mapping, in case they have changed.
     $options = array_intersect_key($this->options['mapping'], $mapping);
     // Get the labels of the fields added to this display.
     $field_labels = $this->displayHandler->getFieldLabels();
     // Provide some default values.
     $defaults = array('#type' => 'select', '#required' => FALSE, '#multiple' => FALSE);
     // For each mapping, add a select element to the form.
     foreach ($options as $key => $value) {
         // If the field is optional, add a 'None' value to the top of the options.
         $field_options = array();
         $required = !empty($mapping[$key]['#required']);
         if (!$required && empty($mapping[$key]['#multiple'])) {
             $field_options = array('' => t('- None -'));
         }
         $field_options += $field_labels;
         // Optionally filter the available fields.
         if (isset($mapping[$key]['#filter'])) {
             $this->view->initHandlers();
             $this::$mapping[$key]['#filter']($field_options);
             unset($mapping[$key]['#filter']);
         }
         // These values must always be set.
         $overrides = array('#options' => $field_options, '#default_value' => $options[$key]);
         // Optionally allow the select to be toggleable.
         if (!empty($mapping[$key]['#toggle'])) {
             $form['mapping']["toggle_{$key}"] = array('#type' => 'checkbox', '#title' => t('Use a custom %field_name', array('%field_name' => strtolower($mapping[$key]['#title']))), '#default_value' => $this->options['mapping']["toggle_{$key}"]);
             $overrides['#states']['visible'][':input[name="style_options[mapping][' . "toggle_{$key}" . ']"]'] = array('checked' => TRUE);
         }
         $form['mapping'][$key] = $overrides + $mapping[$key] + $defaults;
     }
 }