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

Dinesh18 created an issue. See original summary.

nitin.k’s picture

I am also getting this issue. I got this issue when i tried to adding the below code.


 $form['actions']['submit']['#validate'][] = '_some_callback';

This patch might be the savior.

pritam.tiwari’s picture

I 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.

Anonymous’s picture

Just add the form validation method to your button

$form['actions']['publish']['#validate'][] = '::validateForm';

bojanz’s picture

Status: Active » Closed (won't fix)

This is not caused by any code provided by this module.

meangreen’s picture

Thanks 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.

lovegame’s picture

Just use parent::validateForm($form, $form_state);

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
gxleano’s picture

#3 it's working for me.