Support the ongoing development of Laravel.io →
Requests Forms Validation
Last updated 1 year ago.
0

Not exactly what you asked for but this will make sure you get the data you need

$rules['category_id'] = 'required';
$rules['input_name'] = 'required_if:category_id,0';

The way I usually handle this kind of thing is with javascript - I only show the $input_name field when the $category_id is set to 0. When $category_id is set to anything else I clear $input_name and hide the $input_name field. In the event that JS is disabled I just set $input_name to null on save when $category_id = 0

0

Sign in to participate in this thread!

Eventy

Your banner here too?

AtomicRSA atomicrsa Joined 24 Jun 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.