function FieldPluginBase::submitOptionsForm

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::submitOptionsForm()
  2. 8.9.x core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::submitOptionsForm()
  3. 11.x core/modules/views/src/Plugin/views/field/FieldPluginBase.php \Drupal\views\Plugin\views\field\FieldPluginBase::submitOptionsForm()

Performs some cleanup tasks on the options array before saving it.

Overrides PluginBase::submitOptionsForm

1 call to FieldPluginBase::submitOptionsForm()
NumericField::submitOptionsForm in core/modules/views/src/Plugin/views/field/NumericField.php
Performs some cleanup tasks on the options array before saving it.
1 method overrides FieldPluginBase::submitOptionsForm()
NumericField::submitOptionsForm in core/modules/views/src/Plugin/views/field/NumericField.php
Performs some cleanup tasks on the options array before saving it.

File

core/modules/views/src/Plugin/views/field/FieldPluginBase.php, line 541

Class

FieldPluginBase
Base class for views fields.

Namespace

Drupal\views\Plugin\views\field

Code

public function submitOptionsForm(&$form, FormStateInterface $form_state) {
    $options =& $form_state->getValue('options');
    $types = [
        'element_type',
        'element_label_type',
        'element_wrapper_type',
    ];
    $classes = array_combine([
        'element_class',
        'element_label_class',
        'element_wrapper_class',
    ], $types);
    foreach ($types as $type) {
        if (!$options[$type . '_enable']) {
            $options[$type] = '';
        }
    }
    foreach ($classes as $class => $type) {
        if (!$options[$class . '_enable'] || !$options[$type . '_enable']) {
            $options[$class] = '';
        }
    }
    if (empty($options['custom_label'])) {
        $options['label'] = '';
        $options['element_label_colon'] = FALSE;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.