You are here

public function UeditorGlobalSettingsForm::validateForm in UEditor - 百度编辑器 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormBase::validateForm

File

src/Form/UeditorGlobalSettingsForm.php, line 196
Contains \Drupal\ueditor\Form\UeditorGlobalSettingsForm.

Class

UeditorGlobalSettingsForm

Namespace

Drupal\ueditor\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {

  // Check for a new uploaded favicon.
  $file = file_save_upload('watermark_upload', $form['global']['watermark_settings']['watermark_image']['watermark_upload']['#upload_validators'], NULL, 0, FileSystemInterface::EXISTS_REPLACE);
  if (isset($file)) {

    // File attachment was attempted.
    if ($file) {

      // Put the temporary file in form_values so we can save it on submit.
      $form_state
        ->setValue('watermark_upload', $file);
    }
    else {

      // File attachment failed.
      $form_state
        ->setErrorByName('watermark_upload', $this
        ->t('The watermark could not be uploaded.'));
    }
  }
}