You are here

public function FileManagementEditFileForm::validateForm in File Management 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/FileManagementEditFileForm.php, line 143

Class

FileManagementEditFileForm
Provides a form for editing files.

Namespace

Drupal\file_management\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $new_path = $form_state
    ->getValue('new_path');
  $new_filename = $form_state
    ->getValue('new_filename');
  if (strpos($new_path, '.') !== FALSE) {
    $form_state
      ->setErrorByName('new_path', $this
      ->t('You can not specify a filename in the new path.'));
  }
  if (strpos($new_filename, '\\') !== FALSE || strpos($new_filename, '/') !== FALSE) {
    $form_state
      ->setErrorByName('new_filename', $this
      ->t('You can not specify a path in the new filename.'));
  }
}