AnsweredAssumed Answered

Why call bean->save() in before_save logic hook?

Question asked by Yury Voloshin on Mar 3, 2020
Latest reply on Mar 5, 2020 by Yury Voloshin

The documentation on before_save logic hooks states that "calling save on the bean in this hook will cause an infinite loop if not handled correctly". I'm curious, what are the circumstances when you would need to call save on a bean in a before_save logic hook? Since the bean is saved automatically after the before_save hook runs, I can't think of a reason to call save inside the hook.

If there is a good reason to call save in a before_save hook, how can one do it to prevent an infinite loop?

Outcomes