function StyleForm::validateForm
Verifies that the user supplied an image with the form.
Overrides FormBase::validateForm
File
-
modules/
image_example/ src/ Form/ StyleForm.php, line 132
Class
- StyleForm
- Form for interacting with image styles.
Namespace
Drupal\image_example\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if (!$form_state->hasValue('image_fid') || !is_numeric($form_state->getValue('image_fid'))) {
$form_state->setErrorByName('image_fid', $this->t('Please select an image to upload.'));
}
}