Welcome Guest, Not a member yet? Register   Sign In
Different error messages for multiple "required_with" fields?
#1

(This post was last modified: 12-10-2022, 11:43 AM by bassmandc.)

I'm using "required_with" validation on a project with multiple fields.  As per documentation, it's implemented like this:

required_with[field1,field2]

Is it possible to have a different error message when field1 fails versus when field2 fails?  If so, how is that formatted?  I'm looking for something like this:

'example' => [
            'rules'  => 'required_with[field1,field2]',
            'errors' => [
                'required_with.field1' => 'Error message related to field 1',
                'required_with.field2' => 'Error message related to field 2',
            ],
        ],

... but obviously this does not work.  Any guidance appreciated!
Reply
#2

(This post was last modified: 12-13-2022, 09:23 PM by bassmandc.)

I went ahead and just created custom validation rules (and error messages) instead of using the built-in "required_with" rule to achieve this.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB