public function Eva::submitOptionsForm in EVA: Entity Views Attachment 8
Same name and namespace in other branches
- 8.2 src/Plugin/views/display/Eva.php \Drupal\eva\Plugin\views\display\Eva::submitOptionsForm()
Handle any special handling on the validate form.
Overrides DisplayPluginBase::submitOptionsForm
File
- src/
Plugin/ views/ display/ Eva.php, line 215
Class
- Eva
- The plugin that handles an EVA display in views.
Namespace
Drupal\eva\Plugin\views\displayCode
public function submitOptionsForm(&$form, FormStateInterface $form_state) {
parent::submitOptionsForm($form, $form_state);
switch ($form_state
->get('section')) {
case 'entity_type':
$new_entity = $form_state
->getValue('entity_type');
$old_entity = $this
->getOption('entity_type');
$this
->setOption('entity_type', $new_entity);
if ($new_entity != $old_entity) {
// Each entity has its own list of bundles and view modes. If there's
// only one on the new type, we can select it automatically. Otherwise
// we need to wipe the options and start over.
$new_entity_info = \Drupal::entityManager()
->getDefinition($new_entity);
$new_bundles_keys = \Drupal::entityManager()
->getBundleInfo($new_entity);
$new_bundles = array();
if (count($new_bundles_keys) == 1) {
$new_bundles[] = $new_bundles_keys[0];
}
$this
->setOption('bundles', $new_bundles);
}
break;
case 'bundles':
$this
->setOption('bundles', array_values(array_filter($form_state
->getValue('bundles'))));
break;
case 'arguments':
$this
->setOption('argument_mode', $form_state
->getValue('argument_mode'));
if ($form_state
->getValue('argument_mode') == 'token') {
$this
->setOption('default_argument', $form_state
->getValue('default_argument'));
}
else {
$this
->setOption('default_argument', NULL);
}
break;
case 'show_title':
$this
->setOption('show_title', $form_state
->getValue('show_title'));
break;
}
}