1

When updating an entity I want to validate that the fields I am updating are correct. As this may be coming from VBO or a Drupal form I thought I could do it in hook_entity_update.

In hook_entity_update() is there a way to not update the entity and return/display a message.

Maybe I am coming from the wrong angle.

1
  • 1
    I think it would be better to handle it in the form validation. There you can throw errors and highlight the wrong fields prior to saving the entity (which you would do in form submit). Feb 28, 2016 at 1:33

1 Answer 1

0

The right hook for this job is hook_field_attach_validate().

(As implemented by the Field Validation module, which may also do what you want.)

hook_entity_update() actually fires after the entity and all fields have already been saved (in the case of nodes, at least).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.