Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

trondhuso's avatar

Custom FormRequest allow empty select, but then require field content in text input

I have a form where I have a select list where the first value is next to this select box there is an input field. This is used if the select list does not contain a value.

If the user selects the empty select option, then the text field must contain some value. How do I do this in Laravel - form request rules method?

If you feel more information is needed, do not hesitate to ask for more.

0 likes
1 reply
Nakov's avatar

You are looking for required_without rule I guess.

So your for your input field, add this:

'INPUT_FIELD_NAME' => 'required_without:YOUR_SELECT_NAME',

now when the select is empty the input field should be required.

Please or to participate in this conversation.