I have the following form, images, addons, and preferences are repeatable at the first group, item title with price are under preferences group which can be also repeated if needed.
- Q1: Problem is, how to validate these all fields with Laravel 5.8?
- Q2: What should be the naming convention for these fields in HTML form?
Please Note: If any of one field is present in a group the whole group should be mandatory and required.
The current situation is as follows:
I am sending data as follows
Validation Rules in Laravel:
$rules = [
'category_id' => 'required',
'title_en' => 'required',
'title_ar' => 'required',
'price' => 'required',
'images' => 'required',
'images.*' => 'file|max:5120',
'addons_en.*' => 'required_with:addons_ar',
'addons_ar.*' => 'required_with:addons_en',
'preferences.*.title_en' => 'required_with:preferences.*.title_ar',
'preferences.*.title_ar' => 'required_with:preferences.*.title_en',
'preferences.*.item_en.*' => 'required_with:preferences.*.item_ar.*,preferences.*.price.*',
'preferences.*.item_ar.*' => 'required_with:preferences.*.item_en.*,preferences.*.price.*',
'preferences.*.price.*' => 'required_with:preferences.*.item_en.*,preferences.*.item_ar.*',
];
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire