OFFLINE-GmbH / oc-mall-plugin

:convenience_store: E-commerce solution for October CMS
https://offline-gmbh.github.io/oc-mall-plugin
MIT License
169 stars 114 forks source link

Extending Validation Custom Messages #767

Closed artistro08 closed 3 years ago

artistro08 commented 3 years ago

So I'm trying to extend the form rules with my plugin

        VariantModel::extend(function($model) {
            $model->addJsonable('printful_variant_placements');
            $model->addJsonable('printful_variant_placement');
            $model->rules['printful_variant_placements.*.printful_variant_placement'] = "required";
            $model->rules['printful_variant_placements'] = "required_with:printful_variant_id";
            $model->customMessages['printful_variant_placements.required'] = "test";
        }); 

but when I do that, It doesn't like me. I get this error

"Indirect modification of overloaded property OFFLINE\Mall\Models\Variant::$customMessages has no effect" on line 236 of /home/artistro08/.sites/printfulapi/plugins/artistro08/printfulapi/Plugin.php

Am I missing something?

artistro08 commented 3 years ago

The model.afterValidate event worked perfect from OctoberCMS's docs. I was able to filter out the messages based on that.