Hi,
In the event hooks SDK documentation, can you add the information on when the hook onBeforeItemUpsert
is called : before or after the fields validation ? (Event hooks | Documentation — DatoCMS)
Regards
Hi,
In the event hooks SDK documentation, can you add the information on when the hook onBeforeItemUpsert
is called : before or after the fields validation ? (Event hooks | Documentation — DatoCMS)
Regards
Hey @gdoumenc,
I’ll try to update the docs for that shortly, but to answer your question, it happens before serverside validation, and regardless of clientside validation:
false
from onBeforeItemUpsert()
, the validation & save will never happen. The hook intercepts the event and prevents anything from getting sent.true
, the hook will still run first, but then validation & saving will proceed normally.Hope that helps!
I should note that there currently appears to be a bug: If you have a validation error on the form and click Save, but with onBeforeItemUpsert()
returning false
and thus intercepting the request, the clientside form will think the validation succeeded and clear the validation errors.
I’ve reported that to the devs and will update here (and the documentation too) once it’s resolved.
Sorry about that