You are here

class FilterFormatEditForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/filter/src/FilterFormatEditForm.php \Drupal\filter\FilterFormatEditForm
  2. 9 core/modules/filter/src/FilterFormatEditForm.php \Drupal\filter\FilterFormatEditForm

Provides a form for adding a filter format.

@internal

Hierarchy

Expanded class hierarchy of FilterFormatEditForm

File

core/modules/filter/src/FilterFormatEditForm.php, line 13

Namespace

Drupal\filter
View source
class FilterFormatEditForm extends FilterFormatFormBase {

  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
    if (!$this->entity
      ->status()) {
      throw new NotFoundHttpException();
    }
    $form['#title'] = $this->entity
      ->label();
    $form = parent::form($form, $form_state);
    $form['roles']['#default_value'] = array_keys(filter_get_roles_by_format($this->entity));
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    $this
      ->messenger()
      ->addStatus($this
      ->t('The text format %format has been updated.', [
      '%format' => $this->entity
        ->label(),
    ]));
    return $this->entity;
  }

}

Members