You are here

public function AutomatedCropEffect::validateConfigurationForm in Automated Crop 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides ConfigurableImageEffectBase::validateConfigurationForm

File

src/Plugin/ImageEffect/AutomatedCropEffect.php, line 211

Class

AutomatedCropEffect
Provide an Automatic crop tools.

Namespace

Drupal\automated_crop\Plugin\ImageEffect

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  if (!empty($form_state
    ->getValue('aspect_ratio')) && !preg_match(AbstractAutomatedCrop::ASPECT_RATIO_FORMAT_REGEXP, $form_state
    ->getValue('aspect_ratio'))) {
    $form_state
      ->setError($form['aspect_ratio'], $form['aspect_ratio']['#title'] . ': ' . $this
      ->t('Invalid aspect ratio format. Should be defined in H:W form.'));
  }
}