You are here

public function RenameForm::validateForm in Filebrowser 8.2

Same name and namespace in other branches
  1. 3.x src/Form/RenameForm.php \Drupal\filebrowser\Form\RenameForm::validateForm()

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/RenameForm.php, line 134

Class

RenameForm

Namespace

Drupal\filebrowser\Form

Code

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

  // Do not accept path separators into new file names.
  foreach ($form_state
    ->getValue('new_name') as $fid => $new_name) {
    if (strpos($new_name, '/') !== false || strpos($new_name, "\\") !== false) {
      $form_state
        ->setErrorByName('new_name[' . $fid . ']', $this
        ->t('Invalid filename: :filename', [
        ':filename' => $new_name,
      ]));
    }
  }
  parent::validateForm($form, $form_state);
}