Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

array value auto fill in old value laravel 8

<select id="recommended_food"   multiple="multiple" size=3 style='height: 100%;' name="recommended_food[]">
    @if ($food->recomemded_food)
      {{ ($val = 'Fries')
        && $chosen = in_array($val, $food->recommended_food)
        ? 'selected':null}}
      <option value="{{$val}}" {{$chosen}}>{{$val}}</option>
      {{ ($val = 'Hot Dogs')
        && $chosen = in_array($val, $food->recommended_food)
        ? 'selected':null}}
      <option value="{{$val}}" {{$chosen}}>{{$val}}</option>
      {{ ($val = 'Hamburgers')
        && $chosen = in_array($val, $food->recommended_food)
        ? 'selected':null}}
      <option value="{{$val}}" {{$chosen}}>{{$val}}</option>
    @endif
  </select>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #array #auto #fill #laravel
ADD COMMENT
Topic
Name
4+3 =