function ImageEffectFormBase::submitForm

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

Overrides FormInterface::submitForm

File

core/modules/image/src/Form/ImageEffectFormBase.php, line 117

Class

ImageEffectFormBase
Provides a base form for image effects.

Namespace

Drupal\image\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_state->cleanValues();
    // The image effect configuration is stored in the 'data' key in the form,
    // pass that through for submission.
    $this->imageEffect
        ->submitConfigurationForm($form['data'], SubformState::createForSubform($form['data'], $form, $form_state));
    $this->imageEffect
        ->setWeight($form_state->getValue('weight'));
    if (!$this->imageEffect
        ->getUuid()) {
        $this->imageStyle
            ->addImageEffect($this->imageEffect
            ->getConfiguration());
    }
    $this->imageStyle
        ->save();
    $this->messenger()
        ->addStatus($this->t('The image effect was successfully applied.'));
    $form_state->setRedirectUrl($this->imageStyle
        ->toUrl('edit-form'));
}

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