formers / former

A powerful form builder, for Laravel and other frameworks (stand-alone too)
https://formers.github.io/former/
1.34k stars 205 forks source link

error when have id key in the options list of select field #548

Closed vuthaihoc closed 6 years ago

vuthaihoc commented 7 years ago

When my option have an item with key "id", it make label error My config country.list

[
  'id' => 'Indonesia',
  'br' => 'Brazil',
  'mx' => 'Mexico',
  'my' => 'Malaysia',
  'vi' => 'Vietnam',
]
Former::select('filter_country')->options(config('country.list'));

The result

screen shot 2017-07-01 at 17 18 27

Html result

<div class="mb-2 mr-sm-2 mb-sm-0">
  <label for="<option value=" id"="">Indonesia" class="sr-only"&gt;Filter country</label>
  <select class="form-control" id="filter_country" name="filter_country">
    <option value="id">Indonesia</option>
    <option value="br">Brazil</option>
    <option value="mx">Mexico</option>
    <option value="my">Malaysia</option>
    <option value="vi">Vietnam</option>
  </select>
</div>

I found a trick way to fix it

Former::select('filter_country')->options(config('country.list'))->id('filter_country')

But i don't know how to fix it from inner Former's code 😄

claar commented 6 years ago

Good catch -- I think this will simply remain as a "gotcha" for now. Thanks for this issue and for providing the work-around!