dimanche 25 février 2018

Laravel editing a form, getting value for dropdown lists

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>



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

Aucun commentaire:

Enregistrer un commentaire