php - Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs -


i'm learning laravel , creating first form. awesome until want use {{ old('') }} helper in blade file radio buttons. i'm not sure how go doing properly, , can't seem find info on here either.

the code have follows:

<div class="form-group">     <label for="geckohatchling">gecko hatchling?</label>     <div class="radio">         <label>             <input type="radio" name="geckohatchling" id="geckohatchlingyes" value="1">             yes         </label>     </div>     <div class="radio">         <label>             <input type="radio" name="geckohatchling" id="geckohatchlingno" value="0" checked>             no         </label>     </div> </div> 

i think following little bit cleaner:

<input type="radio" name="geckohatchling" id="geckohatchlingyes" value="1" @if(old('geckohatchling')) checked @endif>  <input type="radio" name="geckohatchling" id="geckohatchlingyes" value="1" @if(!old('geckohatchling')) checked @endif> 

@if checking truthiness of old value , outputting checked in either case.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -