Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [Laravel] Walidacja formularza
Puchatek320
post 5.07.2020, 17:50:34
Post #1





Grupa: Zarejestrowani
Postów: 68
Pomógł: 0
Dołączył: 4.11.2019

Ostrzeżenie: (0%)
-----


Cześć, mam pytanie odnośnie walidacji formularzy a dokładnie chodzi o wyświetlanie wiadomości dla użytkownika. Mianowice wyświetla mi się sesji alert "{"film_name":["Wymagane!!!"]} " a chciałbym wyświetlać wiadomość tylko pod inputem a nie w sesji. może ktoś wie jak pominąć wyświetlanie błędu w sesji.
  1. $rules = [
  2. 'film_name' => 'required',
  3. ];
  4.  
  5. $customMessages = [
  6. 'film_name.required' => 'Wymagane!!!'
  7. ];
  8.  
  9. $this->validate($request, $rules, $customMessages);
  10.  


  1.  
  2. @if (\Session::has('success'))
  3. <div class="alert alert-success">
  4. <ul>
  5. {!! \Session::get('success') !!}
  6. </ul>
  7. </div>
  8. @endif
  9.  
  10. @if (\Session::has('errors'))
  11. <div class="alert alert-danger">
  12. <ul>
  13. {!! \Session::get('errors') !!}
  14. </ul>
  15. </div>
  16. @endif
  17.  
  18.  
  19.  
  20. <div class="form-group">
  21. <label for="film_name">Tytuł filmu:</label>
  22. <input type="input" class="form-control" name="film_name" id="film_name" required>
  23. @error('film_name')
  24. <div class="alert alert-danger">{{ $message }}</div>
  25. @enderror
  26. </div>
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.04.2024 - 10:09