public function AspectSwitcherImageEffect::validateConfigurationForm in Image Effects 8
Same name and namespace in other branches
- 8.3 src/Plugin/ImageEffect/AspectSwitcherImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\AspectSwitcherImageEffect::validateConfigurationForm()
- 8.2 src/Plugin/ImageEffect/AspectSwitcherImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\AspectSwitcherImageEffect::validateConfigurationForm()
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/ AspectSwitcherImageEffect.php, line 115
Class
- AspectSwitcherImageEffect
- Choose image styles to apply based on source image orientation.
Namespace
Drupal\image_effects\Plugin\ImageEffectCode
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::validateConfigurationForm($form, $form_state);
if ($form_state
->getValue('portrait_image_style') === NULL && $form_state
->getValue('landscape_image_style') === NULL) {
$form_state
->setErrorByName('portrait_image_style', $this
->t("At least one of 'Landscape image style' or 'Portrait image style' must be selected."));
$form_state
->setErrorByName('landscape_image_style', $this
->t("At least one of 'Landscape image style' or 'Portrait image style' must be selected."));
}
if ($this
->failSafeGetImageStyle($form_state
->getValue('portrait_image_style')) === FALSE) {
$form_state
->setErrorByName('portrait_image_style', $this
->t("The image style does not exist."));
}
if ($this
->failSafeGetImageStyle($form_state
->getValue('landscape_image_style')) === FALSE) {
$form_state
->setErrorByName('landscape_image_style', $this
->t("The image style does not exist."));
}
// @todo at the moment it is not possible to validate the style selected
// not being a circular reference to the current style itself.
// @see https://www.drupal.org/node/1826362
}