本文整理汇总了PHP中Drupal\views\Plugin\views\style\StylePluginBase::buildOptionsForm方法的典型用法代码示例。如果您正苦于以下问题:PHP StylePluginBase::buildOptionsForm方法的具体用法?PHP StylePluginBase::buildOptionsForm怎么用?PHP StylePluginBase::buildOptionsForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\views\Plugin\views\style\StylePluginBase
的用法示例。
在下文中一共展示了StylePluginBase::buildOptionsForm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildOptionsForm
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
// Build the list of skins as options.
$skins = $this->getSkins();
foreach (jcarousel_skins() as $key => $skin) {
$skins[$key] = $skin['title'];
}
$skins[''] = t('None');
// Number of options to provide in count-based options.
$start_range = range(-10, 10);
$range = array_combine($start_range, $start_range);
// Remove '0'.
unset($range[0]);
$auto_range = array('' => t('Auto')) + array_combine(range(1, 10), range(1, 10));
$form['description'] = array('#type' => 'markup', '#value' => '<div class="messages">' . t('The jCarousel style is affected by several other settings within the display. Enable the "Use AJAX" option on your display to have items loaded dynamically. The "Items to display" option will determine how many items are preloaded into the carousel on each AJAX request. Non-AJAX carousels will contain the total number of items set in the "Items to display" option. Carousels may not be used with the "Use pager" option.') . '</div>');
$form['wrap'] = array('#type' => 'select', '#title' => t('Wrap content'), '#default_value' => $this->options['wrap'], '#description' => t('Specifies whether to wrap at the first/last item (or both) and jump back to the start/end.'), '#options' => array(0 => t('Disabled'), 'circular' => t('Circular'), 'both' => t('Both'), 'last' => t('Last'), 'first' => t('First')));
$form['skin'] = array('#type' => 'select', '#title' => t('Skin'), '#default_value' => $this->options['skin'], '#options' => $skins, '#description' => t('Skins may be provided by other modules. Set to "None" if your theme includes carousel theming directly in style.css or another stylesheet. "None" does not include any built-in navigation, arrows, or positioning at all.'));
$form['responsive'] = array('#type' => 'checkbox', '#title' => t('Responsive (number of items)'), '#default_value' => $this->options['responsive'], '#description' => t('Select this option to have the carousel automatically adjust the number of visible items and the number of items to scroll at a time based on the available width.') . ' <strong>' . t('Changing this option will override the "Visible" and "Scroll" options and set carousel orientation to "horizontal".') . '</strong>');
$form['visible'] = array('#type' => 'select', '#title' => t('Number of visible items'), '#options' => $auto_range, '#default_value' => $this->options['visible'], '#description' => t('Set an exact number of items to show at a time. It is recommended to leave set this to "auto", in which the number of items will be determined automatically by the space available to the carousel.') . ' <strong>' . t('Changing this option will override "width" properties set in your CSS.') . '</strong>');
$form['scroll'] = array('#type' => 'select', '#title' => t('Scroll'), '#description' => t('The number of items to scroll at a time. The "auto" setting scrolls all the visible items.'), '#options' => $auto_range, '#default_value' => $this->options['scroll']);
$form['auto'] = array('#type' => 'textfield', '#title' => t('Auto-scroll after'), '#size' => 4, '#maxlength' => 4, '#default_value' => $this->options['auto'], '#field_suffix' => ' ' . t('seconds'), '#description' => t('Specifies how many seconds to periodically auto-scroll the content. If set to 0 (default) then autoscrolling is turned off.'));
$form['navigation'] = array('#type' => 'select', '#title' => t('Enable navigation'), '#options' => array('' => t('None'), 'before' => t('Before'), 'after' => t('After')), '#default_value' => $this->options['navigation'], '#description' => t('Enable a clickable navigation list to jump straight to a given page.'));
$form['ajax'] = array('#type' => 'checkbox', '#title' => t('AJAX load pages'), '#default_value' => $this->options['ajax'], '#description' => t('The number of items set in the pager settings will be preloaded. All additional pages will be loaded by AJAX as needed.'));
$form['advanced'] = array('#type' => 'fieldset', '#title' => t('Advanced'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#parents' => array('style_options'));
$form['advanced']['animation'] = array('#type' => 'textfield', '#title' => t('Animation speed'), '#size' => 10, '#maxlength' => 10, '#default_value' => $this->options['animation'], '#description' => t('The speed of the scroll animation as string in jQuery terms ("slow" or "fast") or milliseconds as integer (See <a href="http://api.jquery.com/animate/">jQuery Documentation</a>).'));
$form['advanced']['easing'] = array('#type' => 'textfield', '#title' => t('Easing effect'), '#size' => 10, '#maxlength' => 128, '#default_value' => $this->options['easing'], '#description' => t('The name of the easing effect that you want to use such as "swing" (the default) or "linear". See list of options in the <a href="http://api.jquery.com/animate/">jQuery Documentation</a>.'));
$form['advanced']['start'] = array('#type' => 'select', '#title' => t('Start position'), '#description' => t('The item that will be shown as the first item in the list upon loading. Useful for starting a list in the middle of a set. A negative value allows choosing an item in the end, e.g. -1 is the last item.'), '#options' => $range, '#default_value' => $this->options['start']);
$form['advanced']['autoPause'] = array('#type' => 'checkbox', '#title' => t('Pause auto-scroll on hover'), '#description' => t('If auto-scrolling, pause the carousel when the user hovers the mouse over an item.'), '#default_value' => $this->options['autoPause']);
$form['advanced']['vertical'] = array('#type' => 'checkbox', '#title' => t('Vertical'), '#description' => t('Specifies wether the carousel appears in horizontal or vertical orientation. Changes the carousel from a left/right style to a up/down style carousel. Defaults to horizontal.'), '#default_value' => $this->options['vertical']);
}
示例2: buildOptionsForm
/**
* Render the given style.
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$form['type'] = array('#type' => 'radios', '#title' => $this->t('List type'), '#options' => array('ul' => $this->t('Unordered list'), 'ol' => $this->t('Ordered list')), '#default_value' => $this->options['type']);
$form['wrapper_class'] = array('#title' => $this->t('Wrapper class'), '#description' => $this->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' => $this->t('List class'), '#description' => $this->t('The class to provide on the list element itself.'), '#type' => 'textfield', '#size' => '30', '#default_value' => $this->options['class']);
}
示例3: buildOptionsForm
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$form['grid_style'] = array('#prefix' => '<h4>Grid Settings</h4>', '#type' => 'select', '#title' => t('Mode'), '#description' => t('Choose grid style:'), '#options' => array('classic' => t('Classic Grid'), 'masonry' => t('Masonry Simple'), 'masonry_resize' => t('Masonry Resize')), '#default_value' => $this->options['grid_style'], '#attributes' => array('class' => array('grid-style')));
$field_options = array();
$fields = \Drupal::entityManager()->getFieldMapByFieldType('image');
foreach ($fields as $field) {
foreach ($field as $key => $value) {
$field_options[$key] = $key;
}
}
$form['masonry_background'] = array('#type' => 'select', '#title' => t('Image'), '#options' => $field_options, '#default_value' => $this->options['masonry_background'], '#states' => array('visible' => array('.grid-style' => array('value' => 'masonry_resize'))));
$form['grid_ratio'] = array('#type' => 'textfield', '#title' => t('Ratio'), '#description' => t('The ratio image'), '#default_value' => $this->options['grid_ratio'], '#states' => array('visible' => array('.grid-style' => array('value' => 'masonry_resize'))));
$form['grid_cols_lg'] = array('#type' => 'select', '#title' => t('Large Desktop Items'), '#description' => t('Number of items on large desktop'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['grid_cols_lg']);
$form['grid_cols_md'] = array('#type' => 'select', '#title' => t('Desktop Items'), '#description' => t('Number of items on desktop'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['grid_cols_md']);
$form['grid_cols_sm'] = array('#type' => 'select', '#title' => t('Tablet Items'), '#description' => t('Number of items on tablet'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['grid_cols_sm']);
$form['grid_cols_xs'] = array('#type' => 'select', '#title' => t('Phone Items'), '#description' => t('Number of items on phone'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['grid_cols_xs']);
$form['grid_margin'] = array('#type' => 'textfield', '#title' => t('Margin'), '#description' => t('The spacing beetween items'), '#default_value' => $this->options['grid_margin'], '#field_suffix' => 'px');
$form['grid_filter'] = array('#type' => 'select', '#title' => t('Use Filter'), '#options' => array(0 => t('No'), 1 => t('Yes')), '#description' => t('Filter items by taxonomy term'), '#default_value' => $this->options['grid_filter'], '#attributes' => array('class' => array('grid-filter-option')));
$categories = array();
$categories['select'] = t('Select');
foreach (Vocabulary::loadMultiple() as $vocabulary) {
$categories[$vocabulary->id()] = $vocabulary->get('name');
}
$form['grid_filter_vocabulary'] = array('#type' => 'select', '#title' => t('Filter Vocabulary'), '#options' => $categories, '#description' => t('Which taxonomy vocabulary do you want to use for the filter'), '#default_value' => $this->options['grid_filter_vocabulary'], '#states' => array('visible' => array('.grid-filter-option' => array('value' => 1))));
}
示例4: buildOptionsForm
/**
* Builds the configuration form.
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$options = array('' => $this->t('- None -'));
$field_labels = $this->displayHandler->getFieldLabels(TRUE);
$options += $field_labels;
$form['date_field'] = array('#type' => 'select', '#title' => $this->t('Date'), '#options' => $options, '#default_value' => $this->options['date_field'], '#description' => $this->t('The field name of the date field that will be used as the date on the timeline.'));
$form['group_heading'] = array('#type' => 'select', '#title' => $this->t('Group heading'), '#options' => array('' => $this->t('No Heading'), 'century' => $this->t('Century'), 'date' => $this->t('Full Date'), 'format' => $this->t('Custom Format')), '#description' => $this->t('The type of date heading to add to the timeline. This heading will be inserted at the first spot where the value of the heading changes.'), '#default_value' => $this->options['group_heading']);
$form['group_heading_format'] = array('#type' => 'textfield', '#title' => $this->t('Group heading format'), '#description' => $this->t("If 'Custom Format' was selected above, input the format string to use for the date heading, using the formats from http://php.net/manual/en/function.date.php. For instance, 'M Y' will display a heading over all items with the same month and year, formatted as 'Jan 2016'."), '#default_value' => $this->options['group_heading_format']);
}
示例5: buildOptionsForm
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$options = array('' => $this->t('- None -'));
$field_labels = $this->displayHandler->getFieldLabels(TRUE);
$options += $field_labels;
$grouping = $this->options['grouping'];
$form['grouping'] = array('#type' => 'select', '#title' => $this->t('Grouping field Nr.@number'), '#options' => $options, '#default_value' => $grouping, '#description' => $this->t('You may optionally specify a field by which to group the records. Leave blank to not group.'));
$a = '';
}
示例6: buildOptionsForm
/**
* {@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']);
}
示例7: buildOptionsForm
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$form['title_field'] = array('#type' => 'select', '#title' => $this->t('Title field'), '#options' => $this->displayHandler->getFieldLabels(TRUE), '#required' => TRUE, '#default_value' => $this->options['title_field'], '#description' => $this->t('Select the field that will be used as the title.'));
$form['accordion_filter'] = array('#type' => 'select', '#title' => t('Use Filter'), '#options' => array(0 => t('No'), 1 => t('Yes')), '#description' => t('Filter items by taxonomy term'), '#default_value' => $this->options['accordion_filter'], '#attributes' => array('class' => array('accordion-filter-option')));
$categories = array();
$categories['select'] = t('Select');
foreach (Vocabulary::loadMultiple() as $vocabulary) {
$categories[$vocabulary->id()] = $vocabulary->get('name');
}
$form['accordion_filter_vocabulary'] = array('#type' => 'select', '#title' => t('Filter Vocabulary'), '#options' => $categories, '#description' => t('Which taxonomy vocabulary do you want to use for the filter'), '#default_value' => $this->options['accordion_filter_vocabulary'], '#states' => array('visible' => array('.accordion-filter-option' => array('value' => 1))));
}
示例8: buildOptionsForm
/**
* Render the given style.
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$form['items'] = array('#type' => 'number', '#title' => $this->t('Items'), '#description' => $this->t('Maximum amount of items displayed at a time with the widest browser width.'), '#default_value' => $this->options['items']);
$form['itemsDesktop'] = array('#type' => 'textfield', '#title' => $this->t('Items Desktop'), '#description' => $this->t('This allows you to preset the number of slides visible with a particular browser width. The format is [x,y] whereby x=browser width and y=number of slides displayed. For example [1199,4] means that if(window<=1199){ show 4 slides per page}'), '#default_value' => $this->options['itemsDesktop']);
$form['itemsDesktopSmall'] = array('#type' => 'textfield', '#title' => $this->t('Items Desktop Small'), '#description' => $this->t('Example: [979,3]'), '#default_value' => $this->options['itemsDesktopSmall']);
$form['itemsTablet'] = array('#type' => 'textfield', '#title' => $this->t('Items Tablet'), '#description' => $this->t('Example: [768,2]'), '#default_value' => $this->options['itemsTablet']);
$form['itemsMobile'] = array('#type' => 'textfield', '#title' => $this->t('Items Mobile'), '#description' => $this->t('Example: [479,1]'), '#default_value' => $this->options['itemsMobile']);
$form['singleItem'] = array('#type' => 'checkbox', '#title' => $this->t('Single Item'), '#default_value' => $this->options['singleItem'], '#description' => $this->t('Display only one item.'));
//itemsScaleUp
$form['itemsScaleUp'] = array('#type' => 'checkbox', '#title' => $this->t('Items ScaleUp'), '#default_value' => $this->options['itemsScaleUp'], '#description' => $this->t('Option to not stretch items when it is less than the supplied items.'));
//slideSpeed
$form['slideSpeed'] = array('#type' => 'number', '#title' => $this->t('Slide Speed'), '#default_value' => $this->options['slideSpeed'], '#description' => $this->t('Slide speed in milliseconds.'));
//paginationSpeed
$form['paginationSpeed'] = array('#type' => 'number', '#title' => $this->t('Pagination Speed'), '#default_value' => $this->options['paginationSpeed'], '#description' => $this->t('Pagination speed in milliseconds.'));
//rewindSpeed
$form['rewindSpeed'] = array('#type' => 'number', '#title' => $this->t('Rewind Speed'), '#default_value' => $this->options['rewindSpeed'], '#description' => $this->t('Rewind speed in milliseconds.'));
//autoPlay
$form['autoPlay'] = array('#type' => 'checkbox', '#title' => $this->t('AutoPlay'), '#default_value' => $this->options['autoPlay']);
//stopOnHover
$form['stopOnHover'] = array('#type' => 'checkbox', '#title' => $this->t('Stop On Hover'), '#default_value' => $this->options['stopOnHover'], '#description' => $this->t('Stop autoplay on mouse hover.'));
//navigation
$form['navigation'] = array('#type' => 'checkbox', '#title' => $this->t('Navigation'), '#default_value' => $this->options['navigation'], '#description' => $this->t('Display "next" and "prev" buttons.'));
//prevText
$form['prevText'] = array('#type' => 'textfield', '#title' => $this->t('Prev Text'), '#default_value' => $this->options['prevText'], '#description' => $this->t('Text for navigation prev button'));
//nextText
$form['nextText'] = array('#type' => 'textfield', '#title' => $this->t('Next Text'), '#default_value' => $this->options['nextText'], '#description' => $this->t('Text for navigation next button'));
//rewindNav
$form['rewindNav'] = array('#type' => 'checkbox', '#title' => $this->t('Rewind Nav'), '#default_value' => $this->options['rewindNav'], '#description' => $this->t('Slide to first item.'));
//scrollPerPage
$form['scrollPerPage'] = array('#type' => 'checkbox', '#title' => $this->t('Scroll Per Page'), '#default_value' => $this->options['scrollPerPage'], '#description' => $this->t('Scroll per page not per item. This affect next/prev buttons and mouse/touch dragging.'));
//pagination
$form['pagination'] = array('#type' => 'checkbox', '#title' => $this->t('pagination'), '#default_value' => $this->options['pagination'], '#description' => $this->t('Show pagination.'));
//paginationNumbers
$form['paginationNumbers'] = array('#type' => 'checkbox', '#title' => $this->t('Pagination Numbers'), '#default_value' => $this->options['paginationNumbers'], '#description' => $this->t('Show numbers inside pagination buttons.'));
//responsive
$form['responsive'] = array('#type' => 'checkbox', '#title' => $this->t('Responsive'), '#default_value' => $this->options['responsive'], '#description' => $this->t('Uncheck to use Owl Carousel on desktop-only.'));
//responsiveRefreshRate
$form['responsiveRefreshRate'] = array('#type' => 'number', '#title' => $this->t('Responsive Refresh Rate'), '#default_value' => $this->options['responsiveRefreshRate'], '#description' => $this->t('Check window width changes every 200ms for responsive actions.'));
//mouseDrag
$form['mouseDrag'] = array('#type' => 'checkbox', '#title' => $this->t('Mouse Drag'), '#default_value' => $this->options['mouseDrag'], '#description' => $this->t('Turn off/on mouse events.'));
//touchDrag
$form['touchDrag'] = array('#type' => 'checkbox', '#title' => $this->t('Touch Drag'), '#default_value' => $this->options['touchDrag'], '#description' => $this->t('Turn off/on touch events.'));
//transitionStyle
$form['transitionStyle'] = array('#type' => 'select', '#options' => array('fade' => $this->t('Fade'), 'backSlide' => $this->t('Back Slide'), 'goDown' => $this->t('Go Down'), 'scaleUp' => $this->t('ScaleUp')), '#title' => $this->t('Transition Style'), '#default_value' => $this->options['transitionStyle'], '#description' => $this->t('Add CSS3 transition style. Works only with one item on screen.'));
}
示例9: buildOptionsForm
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$form['columns'] = array('#type' => 'number', '#title' => $this->t('Number of columns'), '#default_value' => $this->options['columns'], '#required' => TRUE, '#min' => 1);
$form['automatic_width'] = array('#type' => 'checkbox', '#title' => $this->t('Automatic width'), '#description' => $this->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' => $this->t('Alignment'), '#options' => array('horizontal' => $this->t('Horizontal'), 'vertical' => $this->t('Vertical')), '#default_value' => $this->options['alignment'], '#description' => $this->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' => $this->t('Default column classes'), '#description' => $this->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' => $this->t('Custom column class'), '#description' => $this->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'] .= ' ' . $this->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' => $this->t('Default row classes'), '#description' => $this->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' => $this->t('Custom row class'), '#description' => $this->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'] .= ' ' . $this->t('You may use field tokens from as per the "Replacement patterns" used in "Rewrite the output of this field" for all fields.');
}
}
示例10: buildOptionsForm
/**
* Overrides Drupal\views\Plugin\views\style\StylePluginBase::buildOptionsForm().
*/
public function buildOptionsForm(&$form, FormStateInterface $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('' => $this->t('- None -'));
}
$field_options += $field_labels;
// Optionally filter the available fields.
if (isset($mapping[$key]['#filter'])) {
$this->view->initHandlers();
$filter = $mapping[$key]['#filter'];
$this::$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' => $this->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;
}
}
示例11: buildOptionsForm
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$form['grid_padding'] = array('#type' => 'number', '#title' => $this->t('Padding'), '#size' => 2, '#description' => $this->t('The amount of padding in pixels in between grid items.'), '#default_value' => $this->options['grid_padding'], '#maxlength' => 2);
}
示例12: buildOptionsForm
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$form['mode'] = array('#prefix' => '<h4>bxSlider Settings</h4>', '#type' => 'select', '#title' => t('Mode'), '#description' => t('Type of transition between slides'), '#options' => array('horizontal' => t('Horizontal'), 'vertical' => t('Vertical'), 'fade' => t('Fade')), '#default_value' => $this->options['mode']);
$form['ticker'] = array('#type' => 'select', '#title' => t('Ticker Enabled'), '#description' => t('If yes, use slider in ticker mode (similar to a news ticker)'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['ticker']);
$form['tickerHover'] = array('#type' => 'select', '#title' => t('Ticker Hover'), '#description' => t('Ticker will pause when mouse hovers over slider. Note: this functionality does NOT work if using CSS transitions!'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['tickerHover']);
$form['speed'] = array('#type' => 'textfield', '#title' => t('Speed'), '#description' => t('Slide transition duration (in ms)'), '#default_value' => $this->options['speed']);
$form['touchEnabled'] = array('#type' => 'select', '#title' => t('Touch Enabled'), '#description' => t('If yes, slider will allow touch swipe transitions'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['touchEnabled']);
$form['auto'] = array('#type' => 'select', '#title' => t('Auto'), '#description' => t('Slides will automatically transition.'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['auto']);
$form['pause'] = array('#type' => 'textfield', '#title' => t('Pause'), '#description' => t('The amount of time (in ms) between each auto transition.'), '#default_value' => $this->options['pause']);
$form['infiniteloop'] = array('#type' => 'select', '#title' => t('Infinite'), '#description' => t('If true, clicking "Next" while on the last slide will transition to the first slide and vice-versa'), '#options' => array(true => t('Yes'), false => t('No')), '#default_value' => $this->options['infiniteloop']);
$form['slidemargin'] = array('#type' => 'textfield', '#title' => t('Slide Margin'), '#description' => t('Margin between each slide'), '#default_value' => $this->options['slidemargin']);
$form['startslide'] = array('#type' => 'textfield', '#title' => t('Start Slide'), '#description' => t('Starting slide index (zero-based)'), '#default_value' => $this->options['startslide']);
$form['randomstart'] = array('#type' => 'select', '#title' => t('Random Start'), '#options' => array(true => t('Yes'), false => t('No')), '#description' => t('Start slider on a random slide'), '#default_value' => $this->options['randomstart']);
$form['pager'] = array('#type' => 'select', '#title' => t('Show Pager'), '#description' => t('If yes, a pager will be added.'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['pager']);
$form['controls'] = array('#type' => 'select', '#title' => t('Show Controls'), '#description' => t('If yes, next/prev controls will be added.'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['controls']);
$form['nexttext'] = array('#type' => 'textfield', '#title' => t('Custom nextText'), '#description' => t('Custom text to be used for the "Next" control'), '#default_value' => $this->options['nexttext']);
$form['prevtext'] = array('#type' => 'textfield', '#title' => t('Custom prevText'), '#description' => t('Custom text to be used for the "Prev" control'), '#default_value' => $this->options['prevtext']);
$form['autoControls'] = array('#type' => 'select', '#title' => t('Show Auto Controls'), '#description' => t('If Yes, "Start" / "Stop" controls will be added. Note: this functionality work if auto is true!'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['autoControls']);
$form['moveslides'] = array('#type' => 'textfield', '#title' => t('Move Slides'), '#description' => t('The number of slides to move on transition. This value must be >= minSlides, and <= maxSlides. If zero (default), the number of fully-visible slides will be used.'), '#default_value' => $this->options['moveslides']);
$form['lg_items'] = array('#type' => 'select', '#title' => t('Large Desktop Items'), '#description' => t('Number of items on large desktop'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['lg_items']);
$form['md_items'] = array('#type' => 'select', '#title' => t('Desktop Items'), '#description' => t('Number of items on desktop'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['md_items']);
$form['sm_items'] = array('#type' => 'select', '#title' => t('Tablet Items'), '#description' => t('Number of items on tablet'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['sm_items']);
$form['xs_items'] = array('#type' => 'select', '#title' => t('Phone Items'), '#description' => t('Number of items on phone'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['xs_items']);
}
示例13: buildOptionsForm
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$form['formats'] = array('#type' => 'checkboxes', '#title' => $this->t('Accepted request formats'), '#description' => $this->t('Request formats that will be allowed in responses. If none are selected all formats will be allowed.'), '#options' => array_combine($this->formats, $this->formats), '#default_value' => $this->options['formats']);
}
示例14: buildOptionsForm
/**
* Overrides \Drupal\views\Plugin\views\style\StylePluginBase\StylePluginBase::buildOptionsForm().
*/
public function buildOptionsForm(&$form, &$form_state)
{
parent::buildOptionsForm($form, $form_state);
$options = $this->displayHandler->getFieldLabels(TRUE);
$form['search_fields'] = array('#type' => 'checkboxes', '#title' => t('Search fields'), '#options' => $options, '#required' => TRUE, '#default_value' => $this->options['search_fields'], '#description' => t('Select the field(s) that will be searched when using the autocomplete widget.'), '#weight' => -3);
}
示例15: buildOptionsForm
/**
* Render the given style.
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$handlers = $this->displayHandler->getHandlers('field');
if (empty($handlers)) {
$form['error_markup'] = array('#markup' => '<div class="messages messages--error">' . $this->t('You need at least one field before you can configure your table settings') . '</div>');
return;
}
$form['override'] = array('#type' => 'checkbox', '#title' => $this->t('Override normal sorting if click sorting is used'), '#default_value' => !empty($this->options['override']));
$form['sticky'] = array('#type' => 'checkbox', '#title' => $this->t('Enable Drupal style "sticky" table headers (Javascript)'), '#default_value' => !empty($this->options['sticky']), '#description' => $this->t('(Sticky header effects will not be active for preview below, only on live output.)'));
$form['caption'] = array('#type' => 'textfield', '#title' => $this->t('Caption for the table'), '#description' => $this->t('A title semantically associated with your table for increased accessibility.'), '#default_value' => $this->options['caption'], '#maxlength' => 255);
$form['accessibility_details'] = array('#type' => 'details', '#title' => $this->t('Table details'));
$form['summary'] = array('#title' => $this->t('Summary title'), '#type' => 'textfield', '#default_value' => $this->options['summary'], '#fieldset' => 'accessibility_details');
$form['description'] = array('#title' => $this->t('Table description'), '#type' => 'textarea', '#description' => $this->t('Provide additional details about the table to increase accessibility.'), '#default_value' => $this->options['description'], '#states' => array('visible' => array('input[name="style_options[summary]"]' => array('filled' => TRUE))), '#fieldset' => 'accessibility_details');
// Note: views UI registers this theme handler on our behalf. Your module
// will have to register your theme handlers if you do stuff like this.
$form['#theme'] = 'views_ui_style_plugin_table';
$columns = $this->sanitizeColumns($this->options['columns']);
// Create an array of allowed columns from the data we know:
$field_names = $this->displayHandler->getFieldLabels();
if (isset($this->options['default'])) {
$default = $this->options['default'];
if (!isset($columns[$default])) {
$default = -1;
}
} else {
$default = -1;
}
foreach ($columns as $field => $column) {
$column_selector = ':input[name="style_options[columns][' . $field . ']"]';
$form['columns'][$field] = array('#title' => $this->t('Columns for @field', array('@field' => $field)), '#title_display' => 'invisible', '#type' => 'select', '#options' => $field_names, '#default_value' => $column);
if ($handlers[$field]->clickSortable()) {
$form['info'][$field]['sortable'] = array('#title' => $this->t('Sortable for @field', array('@field' => $field)), '#title_display' => 'invisible', '#type' => 'checkbox', '#default_value' => !empty($this->options['info'][$field]['sortable']), '#states' => array('visible' => array($column_selector => array('value' => $field))));
$form['info'][$field]['default_sort_order'] = array('#title' => $this->t('Default sort order for @field', array('@field' => $field)), '#title_display' => 'invisible', '#type' => 'select', '#options' => array('asc' => $this->t('Ascending'), 'desc' => $this->t('Descending')), '#default_value' => !empty($this->options['info'][$field]['default_sort_order']) ? $this->options['info'][$field]['default_sort_order'] : 'asc', '#states' => array('visible' => array($column_selector => array('value' => $field), ':input[name="style_options[info][' . $field . '][sortable]"]' => array('checked' => TRUE))));
// Provide an ID so we can have such things.
$radio_id = Html::getUniqueId('edit-default-' . $field);
$form['default'][$field] = array('#title' => $this->t('Default sort for @field', array('@field' => $field)), '#title_display' => 'invisible', '#type' => 'radio', '#return_value' => $field, '#parents' => array('style_options', 'default'), '#id' => $radio_id, '#attributes' => array('id' => $radio_id), '#default_value' => $default, '#states' => array('visible' => array($column_selector => array('value' => $field))));
}
$form['info'][$field]['align'] = array('#title' => $this->t('Alignment for @field', array('@field' => $field)), '#title_display' => 'invisible', '#type' => 'select', '#default_value' => !empty($this->options['info'][$field]['align']) ? $this->options['info'][$field]['align'] : '', '#options' => array('' => $this->t('None'), 'views-align-left' => $this->t('Left', array(), array('context' => 'Text alignment')), 'views-align-center' => $this->t('Center', array(), array('context' => 'Text alignment')), 'views-align-right' => $this->t('Right', array(), array('context' => 'Text alignment'))), '#states' => array('visible' => array($column_selector => array('value' => $field))));
$form['info'][$field]['separator'] = array('#title' => $this->t('Separator for @field', array('@field' => $field)), '#title_display' => 'invisible', '#type' => 'textfield', '#size' => 10, '#default_value' => isset($this->options['info'][$field]['separator']) ? $this->options['info'][$field]['separator'] : '', '#states' => array('visible' => array($column_selector => array('value' => $field))));
$form['info'][$field]['empty_column'] = array('#title' => $this->t('Hide empty column for @field', array('@field' => $field)), '#title_display' => 'invisible', '#type' => 'checkbox', '#default_value' => isset($this->options['info'][$field]['empty_column']) ? $this->options['info'][$field]['empty_column'] : FALSE, '#states' => array('visible' => array($column_selector => array('value' => $field))));
$form['info'][$field]['responsive'] = array('#title' => $this->t('Responsive setting for @field', array('@field' => $field)), '#title_display' => 'invisible', '#type' => 'select', '#default_value' => isset($this->options['info'][$field]['responsive']) ? $this->options['info'][$field]['responsive'] : '', '#options' => array('' => $this->t('High'), RESPONSIVE_PRIORITY_MEDIUM => $this->t('Medium'), RESPONSIVE_PRIORITY_LOW => $this->t('Low')), '#states' => array('visible' => array($column_selector => array('value' => $field))));
// markup for the field name
$form['info'][$field]['name'] = array('#markup' => $field_names[$field]);
}
// Provide a radio for no default sort
$form['default'][-1] = array('#title' => $this->t('No default sort'), '#title_display' => 'invisible', '#type' => 'radio', '#return_value' => -1, '#parents' => array('style_options', 'default'), '#id' => 'edit-default-0', '#default_value' => $default);
$form['empty_table'] = array('#type' => 'checkbox', '#title' => $this->t('Show the empty text in the table'), '#default_value' => $this->options['empty_table'], '#description' => $this->t('Per default the table is hidden for an empty view. With this option it is possible to show an empty table with the text in it.'));
$form['description_markup'] = array('#markup' => '<div class="js-form-item form-item description">' . $this->t('Place fields into columns; you may combine multiple fields into the same column. If you do, the separator in the column specified will be used to separate the fields. Check the sortable box to make that column click sortable, and check the default sort radio to determine which column will be sorted by default, if any. You may control column order and field labels in the fields section.') . '</div>');
}