当我尝试提交空白表格时,它没有显示错误,只是在主页上重定向

时间:2019-02-13 12:07:10

标签: php laravel-5.7

当我提交空表格时,它不进行验证,并在主页上重定向。我将验证存储在变量中,并放入“ dd($ validation)”,但是当我在字段中输入一些数据时,仅显示我的“ dd($ validation)”输出。我尝试进行配置的过程中发生了什么,请告诉我。

在字段中添加数据后输出

array:1 [▼
  "phone" => "123"
]

当我在主页上提交其重定向为空时

controller.php

public function login(Request $request){
   return view('vendor/voyager/mobileverification');
}

public function loginwithNumber(Request $request)
{
    $user = $request->all();
    // dd($user);
    $dd = $request->validate([
        'phone' => 'required|min:11|numeric'
    ]);
    dd($dd);
}

mobileverification.blade.php

<form class="form-horizontal" id="loginwithNumber" method="POST" action="{{ route('voyager.loginwithnumber') }}">
    @csrf
    <table id="mobilenumber" class="" width="70%" align="center" cellpadding="0" cellspacing="0" border="0" >
        @if (count($errors) > 0)
        <div class="alert alert-danger">
            <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
            </ul>
        </div>
        @endif
        <tr>
            <td>
                <div class="tex">Phone No.<p class="info">(OTP will be sent on this number.)</p></div>
            </td>
        </tr>
        <tr>
            <td>
                <div class="form-group">
                    <input type="text" placeholder="Enter your phone no" name="phone" maxlength="10" id="customer_phone" value="{{ old('phone') }}" autofocus>
                </div>
            </td>
        </tr>

0 个答案:

没有答案