function MediaDevelGenerate::settingsFormValidate
Same name in other branches
- 5.x devel_generate/src/Plugin/DevelGenerate/MediaDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\MediaDevelGenerate::settingsFormValidate()
Overrides DevelGenerateBase::settingsFormValidate
File
-
devel_generate/
src/ Plugin/ DevelGenerate/ MediaDevelGenerate.php, line 232
Class
- MediaDevelGenerate
- Provides a plugin that generates media entities.
Namespace
Drupal\devel_generate\Plugin\DevelGenerateCode
public function settingsFormValidate(array $form, FormStateInterface $form_state) {
// Remove the media types not selected.
$media_types = array_filter($form_state->getValue('media_types'));
if (!$media_types) {
$form_state->setErrorByName('media_types', $this->t('Please select at least one media type'));
}
// Store the normalized value back, in form state.
$form_state->setValue('media_types', array_combine($media_types, $media_types));
}