PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, March 11, 2022

[FIXED] How to show old data of `select` element in Laravel?

 March 11, 2022     html, laravel-5     No comments   

Issue

How to show old data of select element in Laravel?

Data can be shown in input like this:

<input id="name" name="name" class="form-control" type="text" value="{{ old('name', $user->name) }}">

when the element is select,how to show the old data?

<select class="form-control" name="gender">
    <option value="male">male</option>
    <option value="female">female</option>
</select>

Solution

<select class="form-control" name="gender">
    <option value="male" @if (old('gender') == 'male') selected="selected" @endif>male</option>
    <option value="female" @if (old('gender') == 'female') selected="selected" @endif>female</option>
</select>


Answered By - HTMHell
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing