getting_started_with_laravel

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revisionBoth sides next revision
getting_started_with_laravel [03.12.2020 15:46] – [passing variables from content blades to layouts] Pascal Sutergetting_started_with_laravel [03.12.2020 16:10] – [Form validation] Pascal Suter
Line 169: Line 169:
   * in addition to bringing the user back to the form, laravel will provide an ''$error'' variable which can be used in the balde    * in addition to bringing the user back to the form, laravel will provide an ''$error'' variable which can be used in the balde 
   * even better, there is a ''@error(fieldname)'' blade syntax which will do whatever follows after it if the specified field is invalid   * even better, there is a ''@error(fieldname)'' blade syntax which will do whatever follows after it if the specified field is invalid
 +  * you also get a ''old(fieldname)'' function which you can use to populate your input fields with the original inputs, so the user won't have to enter eveything again.. see the eample below. 
 here's an example part of a (bootstrap based) blade with a form that will show some info if the validation fails:  here's an example part of a (bootstrap based) blade with a form that will show some info if the validation fails: 
  
Line 183: Line 183:
       <div class="form-group col-12">       <div class="form-group col-12">
         <label for="inputName">Name</label>         <label for="inputName">Name</label>
-        <input type="text" class="form-control @error('name') is-invalid @enderror" id="inputName" name="name">+        <input type="text" class="form-control @error('name') is-invalid @enderror" id="inputName" name="name" value="{{ old('name') }}">
         <div class="invalid-feedback">Please enter your name here</div>         <div class="invalid-feedback">Please enter your name here</div>
       </div>       </div>
  • getting_started_with_laravel.txt
  • Last modified: 04.12.2020 11:44
  • by Pascal Suter