Global form validation messages

Right now I change the message that the form displays on an error in this way:


public function rules()

    {

        return [

            [['myField1', 'myField2'], 'required', 'message' => 'This is my custom message'],

            [['myField1_id', 'myField2'], 'integer']

        ];

    }

The bad thing if that I have to do for EVERY model that I have. There’s a way to redefine the default error messages?

You can save and retrieve from \config\params.php

for eg:


public function rules()

    {

        return [

            [['myField1', 'myField2'], 'required', 'message' => Yii::$app->params['reqMsg']],

            [['myField1_id', 'myField2'], 'integer']

        ];

    }

Ok will try that!

http://www.yiiframework.com/doc-2.0/guide-concept-di-container.html#practical-usage