trait WebformEntityOptionsTrait in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformEntityOptionsTrait.php \Drupal\webform\Plugin\WebformElement\WebformEntityOptionsTrait
Provides an 'entity_reference' with options trait.
Hierarchy
- trait \Drupal\webform\Plugin\WebformElement\WebformEntityOptionsTrait
1 file declares its use of WebformEntityOptionsTrait
- WebformOptionsCustomEntity.php in modules/
webform_options_custom/ src/ Plugin/ WebformElement/ WebformOptionsCustomEntity.php
File
- src/
Plugin/ WebformElement/ WebformEntityOptionsTrait.php, line 10
Namespace
Drupal\webform\Plugin\WebformElementView source
trait WebformEntityOptionsTrait {
/**
* {@inheritdoc}
*/
protected function defineDefaultProperties() {
$properties = parent::defineDefaultProperties() + [
// Entity reference settings.
'target_type' => '',
'selection_handler' => '',
'selection_settings' => [],
];
unset($properties['options'], $properties['options_description_display']);
switch ($this
->getPluginId()) {
case 'webform_entity_checkboxes':
// Remove 'None of the above' options.
unset($properties['options_none'], $properties['options_none_value'], $properties['options_none_text']);
break;
case 'webform_entity_radios':
// Remove format multiple items.
unset($properties['format_items'], $properties['format_items_html'], $properties['format_items_text']);
break;
}
return $properties;
}
/****************************************************************************/
/**
* {@inheritdoc}
*/
public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) {
$this
->setOptions($element, [
'webform_submission' => $webform_submission,
]);
parent::prepare($element, $webform_submission);
}
/**
* {@inheritdoc}
*/
protected function getElementSelectorInputsOptions(array $element) {
$this
->setOptions($element);
return parent::getElementSelectorInputsOptions($element);
}
/**
* {@inheritdoc}
*/
public function getElementSelectorSourceValues(array $element) {
$this
->setOptions($element);
return parent::getElementSelectorSourceValues($element);
}
/**
* {@inheritdoc}
*/
public function getExportDefaultOptions() {
return [
'entity_reference_items' => [
'id',
'title',
'url',
],
'options_single_format' => 'compact',
'options_multiple_format' => 'compact',
'options_item_format' => 'label',
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WebformEntityOptionsTrait:: |
protected | function | 2 | |
WebformEntityOptionsTrait:: |
protected | function | 1 | |
WebformEntityOptionsTrait:: |
public | function | ||
WebformEntityOptionsTrait:: |
public | function | ||
WebformEntityOptionsTrait:: |
public | function |