samedi 9 février 2019

How to make one validation error for 2 fields

I have 2 fields for postal code main and sub.

<input type="text" name="postal01">
<input type="text" name="postal02">

I would like to have validation for numeric and size of both fields added. What I want to do is showing validation error for one field as postal_cd, not each field error.

I had tried in a request class extended FormRequest.

class MemberRequest extends FormRequest
{
  public function all($keys = null)
  {
    $result = parent::all($keys);

    if($this->filled('postal01') && $this->filled('postal02')) {
        $results['postal_code'] = $this->input('postal01') . $this->input('postal02');
    }
    return $result;
}

However it did not work like I expected.

How can I handle this case?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire