function Field::multiple_options_form in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Plugin/views/field/Field.php \Drupal\views\Plugin\views\field\Field::multiple_options_form()
Provide options for multiple value fields.
1 call to Field::multiple_options_form()
- Field::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ field/ Field.php - Default options form that provides the label widget that all fields should have.
File
- core/
modules/ views/ src/ Plugin/ views/ field/ Field.php, line 499 - Contains \Drupal\views\Plugin\views\field\Field.
Class
- Field
- A field that displays entity field data.
Namespace
Drupal\views\Plugin\views\fieldCode
function multiple_options_form(&$form, FormStateInterface $form_state) {
$field = $this
->getFieldDefinition();
$form['multiple_field_settings'] = array(
'#type' => 'details',
'#title' => $this
->t('Multiple field settings'),
'#weight' => 5,
);
$form['group_rows'] = array(
'#title' => $this
->t('Display all values in the same row'),
'#type' => 'checkbox',
'#default_value' => $this->options['group_rows'],
'#description' => $this
->t('If checked, multiple values for this field will be shown in the same row. If not checked, each value in this field will create a new row. If using group by, please make sure to group by "Entity ID" for this setting to have any effect.'),
'#fieldset' => 'multiple_field_settings',
);
// Make the string translatable by keeping it as a whole rather than
// translating prefix and suffix separately.
list($prefix, $suffix) = explode('@count', $this
->t('Display @count value(s)'));
if ($field
->getCardinality() == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
$type = 'textfield';
$options = NULL;
$size = 5;
}
else {
$type = 'select';
$range = range(1, $field
->getCardinality());
$options = array_combine($range, $range);
$size = 1;
}
$form['multi_type'] = array(
'#type' => 'radios',
'#title' => $this
->t('Display type'),
'#options' => array(
'ul' => $this
->t('Unordered list'),
'ol' => $this
->t('Ordered list'),
'separator' => $this
->t('Simple separator'),
),
'#states' => array(
'visible' => array(
':input[name="options[group_rows]"]' => array(
'checked' => TRUE,
),
),
),
'#default_value' => $this->options['multi_type'],
'#fieldset' => 'multiple_field_settings',
);
$form['separator'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Separator'),
'#default_value' => $this->options['separator'],
'#states' => array(
'visible' => array(
':input[name="options[group_rows]"]' => array(
'checked' => TRUE,
),
':input[name="options[multi_type]"]' => array(
'value' => 'separator',
),
),
),
'#fieldset' => 'multiple_field_settings',
);
$form['delta_limit'] = array(
'#type' => $type,
'#size' => $size,
'#field_prefix' => $prefix,
'#field_suffix' => $suffix,
'#options' => $options,
'#default_value' => $this->options['delta_limit'],
'#prefix' => '<div class="container-inline">',
'#states' => array(
'visible' => array(
':input[name="options[group_rows]"]' => array(
'checked' => TRUE,
),
),
),
'#fieldset' => 'multiple_field_settings',
);
list($prefix, $suffix) = explode('@count', $this
->t('starting from @count'));
$form['delta_offset'] = array(
'#type' => 'textfield',
'#size' => 5,
'#field_prefix' => $prefix,
'#field_suffix' => $suffix,
'#default_value' => $this->options['delta_offset'],
'#states' => array(
'visible' => array(
':input[name="options[group_rows]"]' => array(
'checked' => TRUE,
),
),
),
'#description' => $this
->t('(first item is 0)'),
'#fieldset' => 'multiple_field_settings',
);
$form['delta_reversed'] = array(
'#title' => $this
->t('Reversed'),
'#type' => 'checkbox',
'#default_value' => $this->options['delta_reversed'],
'#suffix' => $suffix,
'#states' => array(
'visible' => array(
':input[name="options[group_rows]"]' => array(
'checked' => TRUE,
),
),
),
'#description' => $this
->t('(start from last values)'),
'#fieldset' => 'multiple_field_settings',
);
$form['delta_first_last'] = array(
'#title' => $this
->t('First and last only'),
'#type' => 'checkbox',
'#default_value' => $this->options['delta_first_last'],
'#suffix' => '</div>',
'#states' => array(
'visible' => array(
':input[name="options[group_rows]"]' => array(
'checked' => TRUE,
),
),
),
'#fieldset' => 'multiple_field_settings',
);
}