samedi 8 septembre 2018

laravelcollective: add extra attribute to each options(Form::Select)

<select class="form-control" id="user" name="car">
  <option value="0" selected="selected">Select Cars</option>
  <option dta-img='1.jpg' value="134">Volvo</option>
  <option dta-img='2.jpg' value="135">Noah</option>
  <option dta-img='3.jpg' value="136">Marcidis</option>
  <option dta-img='4.jpg' value="143">London Express</option>
</select>

My array for options :

public function guardianList()
    {
      $list = ["Select Cars"];
        foreach ($carss->all() as $car) {
            $list[$car->id] =  $car->name;
        }
        return $list;
}

   Form::select('car',$list, null, null);

How can i add extra dynamic html attribute to all options? I want to show image infront of every option in jquery select2. For that i need to send image from Form::Select(). I there any easy way to do that without using marcos?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2CyTXyP
via IFTTT

Aucun commentaire:

Enregistrer un commentaire