Calculate field value before save

Posted 2 years ago by mistre83

Hi to all,

in my database table i have a field that cant be assigned and its' value is calculated. So, before insert or update the model, i have to compute the value, for example:

In my case, the field in a image name that should be renamed before save, in this way:

image_name -> img_1_4 (where 1 and 4 are some model property / relation).

This value do not depend on current image_name (so setImageNameAttribute is not my case).

To to this, i should use Observer or there are other way ?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.