i have one form which has 4 text fields. I want Laravel to check if the fields are field, but it does not need to check all of them, just only two of them.
Example: field1, field2, field3, field4. To complete the form the user must enter values for field1 and field2 or for field3 and field4.
Is this possible ?
i will post the answer if somebody needs it in future. I have one field (price), which is always required. Than i have three additional fields where the combination field (volume) or fields (buy, sell) is also required.
Here is the solution:
return [
'price' => ['required'],
'volume' => ['required_without_all:buy,sell'],
'buy' => ['required_without:volume'],
'sell' => ['required_without:volume'],
];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.