public function OptionsBase::buildExportOptionsForm in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/OptionsBase.php \Drupal\webform\Plugin\WebformElement\OptionsBase::buildExportOptionsForm()
Get an element's export options webform.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
array $export_options: An associative array of default values.
Return value
array An associative array contain an element's export option webform.
Overrides WebformElementBase::buildExportOptionsForm
File
- src/
Plugin/ WebformElement/ OptionsBase.php, line 573
Class
- OptionsBase
- Provides a base 'options' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function buildExportOptionsForm(array &$form, FormStateInterface $form_state, array $export_options) {
parent::buildExportOptionsForm($form, $form_state, $export_options);
if (isset($form['options'])) {
return;
}
// Build format options with help.
$options_format_options = [
'compact' => $this
->t('Compact, with the option values delimited by commas in one column.') . WebformOptionsHelper::DESCRIPTION_DELIMITER . $this
->t('Compact options are more suitable for importing data into other systems.'),
'separate' => $this
->t('Separate, with each possible option value in its own column.') . WebformOptionsHelper::DESCRIPTION_DELIMITER . $this
->t('Separate options are more suitable for building reports, graphs, and statistics in a spreadsheet application. Ranking will be included for sortable option elements.'),
];
$form['options'] = [
'#type' => 'details',
'#title' => $this
->t('Select menu, radio buttons, and checkboxes options'),
'#open' => TRUE,
'#weight' => -10,
];
$form['options']['options_single_format'] = [
'#type' => 'radios',
'#title' => $this
->t('Options single value format'),
'#description' => $this
->t('Elements that collect a single option value include select menus, radios, and buttons.'),
'#options' => $options_format_options,
'#options_description_display' => 'help',
'#default_value' => $export_options['options_single_format'],
];
$form['options']['options_multiple_format'] = [
'#type' => 'radios',
'#title' => $this
->t('Options multiple values format'),
'#description' => $this
->t('Elements that collect multiple option values include multi-select, checkboxes, and toggles.'),
'#options' => $options_format_options,
'#options_description_display' => 'help',
'#default_value' => $export_options['options_multiple_format'],
];
$form['options']['options_item_format'] = [
'#type' => 'radios',
'#title' => $this
->t('Options item format'),
'#options' => [
'label' => $this
->t('Option labels, the human-readable value (label)'),
'key' => $this
->t('Option values, the raw value stored in the database (key)'),
],
'#default_value' => $export_options['options_item_format'],
];
}