public function FeedForm::validateForm in Feeds 8.3
@todo Don't call buildEntity() here.
Overrides ContentEntityForm::validateForm
File
- src/
FeedForm.php, line 133
Class
- FeedForm
- Form controller for the feed edit forms.
Namespace
Drupal\feedsCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if ($form_state
->getErrors()) {
return;
}
$feed = $this
->buildEntity($form, $form_state);
foreach ($feed
->getType()
->getPlugins() as $type => $plugin) {
if (!$this
->pluginHasForm($plugin, 'feed')) {
continue;
}
$feed_form = $this->formFactory
->createInstance($plugin, 'feed');
$plugin_state = (new FormState())
->setValues($form_state
->getValue([
'plugin',
$type,
], []));
$feed_form
->validateConfigurationForm($form['plugin'][$type], $plugin_state, $feed);
$form_state
->setValue([
'plugin',
$type,
], $plugin_state
->getValues());
foreach ($plugin_state
->getErrors() as $name => $error) {
// Remove duplicate error messages.
if (!empty($_SESSION['messages']['error'])) {
foreach ($_SESSION['messages']['error'] as $delta => $message) {
if ($message['message'] === $error) {
unset($_SESSION['messages']['error'][$delta]);
break;
}
}
}
$form_state
->setErrorByName($name, $error);
}
}
parent::validateForm($form, $form_state);
}