Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

How to manipulate data saved to database


I have a simple products module.

When the user creates a product, I want one of the fields to be save in uppercase to the database.

I think I should use the model hook: on_before_save but I can't find any example of where to put this hook and how to actually use it.

Do I put in the the products model file? Where? how?

Can anyone point me to the right documentation or give me an example on how to use this hook?


  • Found the answer, thx

    In the products_model file, under:
    class Products_model extends Base_module_model {

    I added this function:
    public function on_before_save($values) { $values = parent::on_before_save($values); $values['product_code'] = strtoupper($values['product_code']); return $values; }

Sign In or Register to comment.