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
Post a Comment