I have added a custom validation in hook_form_alter, but it throws below error :
Custom Validation added
$form['actions']['publish']['#validate'][] = 'media_helper_form_validate_handler';
$form['actions']['unpublish']['#validate'][] = 'media_helper_form_validate_handler';
Error Thrown :
Drupal\Core\Entity\EntityStorageException: Entity validation was skipped. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 770 of D:\xampp\htdocs\drupal-8\core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php).
LogicException: Entity validation was skipped. in Drupal\Core\Entity\ContentEntityBase->preSave() (line 353 of D:\xampp\htdocs\drupal-8\core\lib\Drupal\Core\Entity\ContentEntityBase.php).
Kindly help me on this.
Comments
Comment #2
nitin.k CreditAttribution: nitin.k as a volunteer and commentedI am also getting this issue. I got this issue when i tried to adding the below code.
This patch might be the savior.
Comment #3
pritam.tiwari CreditAttribution: pritam.tiwari commentedI had also faced the same issue. I managed the form submission with following line of code. Add following line of code in your form's custom validate function.
$form_state->setTemporaryValue('entity_validated', TRUE);
Hope this may be useful to someone.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedJust add the form validation method to your button
$form['actions']['publish']['#validate'][] = '::validateForm';
Comment #5
bojanz CreditAttribution: bojanz at Centarro commentedThis is not caused by any code provided by this module.
Comment #6
meangreen CreditAttribution: meangreen commentedThanks pritamtiwari09@gmail_dot_com,
I was having that exact same issue and I was going crazy and your line of code fixed it. It DID help me.
I think* this is a bug (somewhere at least), I had my validation function empty at first and this exception would happen just on that.
If I would put a $form_state->setErrorByName in it, suddenly it would work (of course it'd throw the error).
I then put your line of code at the end of my function and it fixed it.
Comment #7
lovegame CreditAttribution: lovegame commentedJust use parent::validateForm($form, $form_state);
Comment #8
gxleano CreditAttribution: gxleano commented#3 it's working for me.