За последние 24 часа нас посетили 22286 программистов и 1060 роботов. Сейчас ищут 647 программистов ...

Почему ошибки не показываются в форме?

Тема в разделе "Laravel", создана пользователем boss1, 25 фев 2021.

  1. boss1

    boss1 Новичок

    С нами с:
    18 фев 2021
    Сообщения:
    70
    Симпатии:
    0
    Почему ошибки не показываются в форме?
    Код (Text):
    1.  
    2.  
    3.  
    4. @extends('default.layouts.layout')
    5.  
    6.  
    7. <div class="col-md-9">
    8.  
    9.      <pre>
    10.      {{ print_r(Session::all()) }}
    11.      </pre>
    12.    
    13.    <div class="">
    14.      <h2>Contact us!</h2>
    15.   </div>
    16.  
    17.    <p>
    18.    This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.
    19.    </p>
    20.    @section('content')
    21.      @if(count($errors) > 0)
    22.        <div class="alert alert-danger">
    23.          <ul>
    24.            @foreach($errors->all() as $error)
    25.              <li>{{ $error}}</li>
    26.            @endforeach
    27.  
    28.          </ul>
    29.        </div>
    30.      @endif
    31.  
    32.    <form method="post" action="{{ route('contact',array('name'=>'hello')) }}">
    33.      {{ csrf_field() }}
    34.     <div class="form-group">
    35.     <label for="name">Name</label>
    36.     <input type="text" class="form-control" id="name" name="name" value="{{ old('name') }}" placeholder="Jane Doe">
    37.     </div>
    38.     <div class="form-group">
    39.     <label for="email">Email address</label>
    40.     <input type="email" class="form-control" id="email" value="{{ old('email') }}" name="email" placeholder="Email">
    41.     </div>
    42.     <div class="form-group">
    43.     <label for="site">Site</label>
    44.     <input type="text" class="form-control" id="site" value="{{ old('site') }}" name="site" placeholder="Site">
    45.     </div>
    46.     <div class="form-group">
    47.     <label for="text">Text</label>
    48.     <textarea class="form-control" id="text" name="text" rows="3">{{ old('text') }}</textarea>
    49.     </div>
    50.     <button type="submit" class="btn btn-primary">Submit</button>
    51.    </form>
    52. </div>  
    53. @endsection
    54.  
    55. <?php
    56.  
    57. namespace App\Http\Controllers\Admin;
    58.  
    59. use Illuminate\Http\Request;
    60.  
    61. use App\Http\Requests;
    62. use App\Http\Controllers\Controller;
    63.  
    64.  
    65. class ContactController extends Controller
    66. {
    67.  
    68.   public function show(Request $request,$id=FALSE) {
    69.  
    70.   if($request->isMethod('post')) {
    71.  
    72.   $rules = [
    73.  
    74.   'name'=>'unique:users,name',
    75.   //'email'=>'required|email'
    76.  
    77.   ];
    78.  
    79.   $this->validate($request,$rules);
    80.  
    81.   // kod
    82.   dump($request->all());
    83.  
    84.  
    85.   }
    86.  
    87.   return view('default.contact',['title'=>'Contacts']);  }
    88. }


    Наверное может потому что count($errors) == 0.?
     
  2. TeslaFeo

    TeslaFeo Старожил

    С нами с:
    9 мар 2016
    Сообщения:
    2.989
    Симпатии:
    759
    да, точно поэтому :)
    доку читай
     
  3. boss1

    boss1 Новичок

    С нами с:
    18 фев 2021
    Сообщения:
    70
    Симпатии:
    0
    спасибо КЭП