mercredi 25 janvier 2017

Laravel Validation with checkbox

If use_shipping is un-checked and user did not enter the value in the shipping_note - validation should have passed but it has failed?

<input type="hidden" name="use_shipping" value="0">
<input type="checkbox" name="use_shipping" value="1" >

Text

<input type="text" name="shipping_note" value="">

In Laravel request class:

public function rules()
{

    return [
        'use_shipping'  => 'boolean',
        'shipping_note' => 'required_with:use_shipping',
    ];
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire