function Entity::buildOptionsForm
Same name in this branch
- 10 core/modules/views/src/Plugin/views/area/Entity.php \Drupal\views\Plugin\views\area\Entity::buildOptionsForm()
Same name in other branches
- 9 core/modules/views/src/Plugin/views/argument_validator/Entity.php \Drupal\views\Plugin\views\argument_validator\Entity::buildOptionsForm()
- 9 core/modules/views/src/Plugin/views/area/Entity.php \Drupal\views\Plugin\views\area\Entity::buildOptionsForm()
- 8.9.x core/modules/views/src/Plugin/views/argument_validator/Entity.php \Drupal\views\Plugin\views\argument_validator\Entity::buildOptionsForm()
- 8.9.x core/modules/views/src/Plugin/views/area/Entity.php \Drupal\views\Plugin\views\area\Entity::buildOptionsForm()
- 11.x core/modules/views/src/Plugin/views/argument_validator/Entity.php \Drupal\views\Plugin\views\argument_validator\Entity::buildOptionsForm()
- 11.x core/modules/views/src/Plugin/views/area/Entity.php \Drupal\views\Plugin\views\area\Entity::buildOptionsForm()
Overrides ArgumentValidatorPluginBase::buildOptionsForm
2 calls to Entity::buildOptionsForm()
- TermName::buildOptionsForm in core/
modules/ taxonomy/ src/ Plugin/ views/ argument_validator/ TermName.php - User::buildOptionsForm in core/
modules/ user/ src/ Plugin/ views/ argument_validator/ User.php
2 methods override Entity::buildOptionsForm()
- TermName::buildOptionsForm in core/
modules/ taxonomy/ src/ Plugin/ views/ argument_validator/ TermName.php - User::buildOptionsForm in core/
modules/ user/ src/ Plugin/ views/ argument_validator/ User.php
File
-
core/
modules/ views/ src/ Plugin/ views/ argument_validator/ Entity.php, line 96
Class
- Entity
- Defines an argument validator plugin for each entity type.
Namespace
Drupal\views\Plugin\views\argument_validatorCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$entity_type_id = $this->definition['entity_type'];
// Derivative IDs are all entity:entity_type. Sanitized for js.
// The ID is converted back on submission.
$sanitized_id = ArgumentPluginBase::encodeValidatorId($this->definition['id']);
$entity_type = $this->entityTypeManager
->getDefinition($entity_type_id);
// If the entity has bundles, allow option to restrict to bundle(s).
if ($entity_type->hasKey('bundle')) {
$bundle_options = [];
foreach ($this->entityTypeBundleInfo
->getBundleInfo($entity_type_id) as $bundle_id => $bundle_info) {
$bundle_options[$bundle_id] = $bundle_info['label'];
}
$form['bundles'] = [
'#title' => $entity_type->getBundleLabel() ?: $this->t('Bundles'),
'#default_value' => $this->options['bundles'],
'#type' => 'checkboxes',
'#options' => $bundle_options,
'#description' => $this->t('If none are selected, all are allowed.'),
];
}
// Offer the option to filter by access to the entity in the argument.
$form['access'] = [
'#type' => 'checkbox',
'#title' => $this->t('Validate user has access to the %name', [
'%name' => $entity_type->getLabel(),
]),
'#default_value' => $this->options['access'],
];
$form['operation'] = [
'#type' => 'radios',
'#title' => $this->t('Access operation to check'),
'#options' => [
'view' => $this->t('View'),
'update' => $this->t('Edit'),
'delete' => $this->t('Delete'),
],
'#default_value' => $this->options['operation'],
'#states' => [
'visible' => [
':input[name="options[validate][options][' . $sanitized_id . '][access]"]' => [
'checked' => TRUE,
],
],
],
];
// If class is multiple capable give the option to validate single/multiple.
if ($this->multipleCapable) {
$form['multiple'] = [
'#type' => 'radios',
'#title' => $this->t('Multiple arguments'),
'#options' => [
0 => $this->t('Single ID', [
'%type' => $entity_type->getLabel(),
]),
1 => $this->t('One or more IDs separated by , or +', [
'%type' => $entity_type->getLabel(),
]),
],
'#default_value' => (string) $this->options['multiple'],
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.