vendredi 1 décembre 2017

custom message for dependency required field

I have 3 fields - type(hw/sw),hardware type(dropdown) and asset_request.'Type' field is dropdown hardware(1) and software(2).'hardware type' has phone(1),camera(2),others(3)

If I chosen hardware(1),hardware type field is mandary and asset_request field is not mandatory.

If I chosen software(0) only asset_request field is mandatory.

If I chosen type=hardware(1) and hardware type=others(3) asset_request field is mandatory. so my validation is like

$this->validate($request,[
                'hardware_type' => 'required_without:asset_request',
                'asset_request' => 'required_without:hardware_type|required_if:hardware_type,==,3',

            ],$messages);

if I filled type and left hardware type now display the message.I want to display only one error message.Is it possible to do foe dependency fields.

The hardware type field is required when asset request is not present.
The asset request field is required when hardware type is not present.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2jCtKCY
via IFTTT

Aucun commentaire:

Enregistrer un commentaire