Have a look at required_if, required_with, ... here: https://laravel.com/docs/5.6/validation
Advanced validation
Hi There,
I have a form that has a few variable sections... for example, I have a select dropdown for employment_status. If a user selects 'Employed' then a number of new fields would appear below (employer_name, job_role, annual_salary). But if they selected 'Unemployed' these extra fields would stay hidden.
My question is how I go about validating these with Laravel. I can't just set them as required because sometimes they may just stay hidden. I've read a bit about the custom conditional validation you can do, but didn't quite understand how to implement it, so wondering if someone could help?
Thanks in advance!
Please or to participate in this conversation.