I had a user submit a form, and some of the fields were dropdowns like so
<div class="form-group row">
<label for="type" class="col-md-3 col-form-label text-md-right">Type</label>
<div class="col-md-9">
<select class ="form-control" id="type" name="type">
<option>Apartment</option>
<option>House</option>
<option>Studio</option>
<option>Flat</option>
</select>
@if ($errors->has('type'))
<span class="invalid-feedback">
<strong></strong>
</span>
@endif
</div>
</div>
That works just fine.
I'm no trying to allow users to edit a particular form. I can get other sections like title and photo by assigning a value to the input and calling the data like this
<input id="Address" type="text" class="form-control" name="address" value="" required autofocus>
But when I attempt to do something similar on a select option, nothing appears. This is a dropdown on the edit page.
<div class="form-group row">
<label for="type" class="col-md-3 col-form-label text-md-right">Type</label>
<div class="col-md-9">
<select class ="form-control" id="type" name="type" value="">
<option></option>
<option>Apartment</option>
<option>House</option>
<option>Studio</option>
<option>Flat</option>
</select>
@if ($errors->has('type'))
<span class="invalid-feedback">
<strong></strong>
</span>
@endif
</div>
</div>
Now I can do what I need to like so with hardcoded valuess
<select class ="form-control" id="type" name="type">
<option value="">Select</option>
<option >Apartment</option>
<option >House</option>
<option >Studio</option>
<option >Flat</option>
</select>
But i doesn't work with a for each loop querying a db
@foreach ($Advert as $type)
<option ' ? 'selected':'' }}></option>
@endforeach
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire