vendredi 22 juillet 2016

Laravel Validation If checkbox ticked then Input text is required?

I have been reading Laravel validation documentation. I am not clear how to combine two rules.

For example:

<input type="checkbox" name="has_login" value="1">

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

If has_login checkbox is ticked then Input text pin value is required.

If has_login is not ticked then Input text pin is not required.

Laravel Validation:

public function rules()
{
    return [
          'has_login' => 'accepted',
          'pin' => 'required',
    ];
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire