function FilterFormatFormBase::submitForm

Same name in other branches
  1. 8.9.x core/modules/filter/src/FilterFormatFormBase.php \Drupal\filter\FilterFormatFormBase::submitForm()
  2. 10 core/modules/filter/src/FilterFormatFormBase.php \Drupal\filter\FilterFormatFormBase::submitForm()
  3. 11.x core/modules/filter/src/FilterFormatFormBase.php \Drupal\filter\FilterFormatFormBase::submitForm()

Overrides EntityForm::submitForm

2 calls to FilterFormatFormBase::submitForm()
FilterFormatAddForm::submitForm in core/modules/filter/src/FilterFormatAddForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…
FilterFormatEditForm::submitForm in core/modules/filter/src/FilterFormatEditForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…
2 methods override FilterFormatFormBase::submitForm()
FilterFormatAddForm::submitForm in core/modules/filter/src/FilterFormatAddForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…
FilterFormatEditForm::submitForm in core/modules/filter/src/FilterFormatEditForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…

File

core/modules/filter/src/FilterFormatFormBase.php, line 199

Class

FilterFormatFormBase
Provides a base form for a filter format.

Namespace

Drupal\filter

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    // Add the submitted form values to the text format, and save it.
    $format = $this->entity;
    foreach ($form_state->getValues() as $key => $value) {
        if ($key != 'filters') {
            $format->set($key, $value);
        }
        else {
            foreach ($value as $instance_id => $config) {
                $format->setFilterConfig($instance_id, $config);
            }
        }
    }
    $format->save();
    // Save user permissions.
    if ($permission = $format->getPermissionName()) {
        foreach ($form_state->getValue('roles') as $rid => $enabled) {
            user_role_change_permissions($rid, [
                $permission => $enabled,
            ]);
        }
    }
    return $this->entity;
}

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