kristijanhusak / laravel-form-builder

Laravel Form builder for version 5+!
https://packagist.org/packages/kris/laravel-form-builder
MIT License
1.7k stars 298 forks source link

how to prevent the form builder to add a selected="selected" on the first item #331

Open lsmith77 opened 7 years ago

lsmith77 commented 7 years ago

when using vue.js, selected state should be set by vue.js, so it would be good to disable this.

Hacky solution was to just set selected to []:

            ->add('last_name', 'text', [
                'label' => 'name',
                // https://www.reddit.com/r/vuejs/comments/4tdevt/why_doesnt_this_work_with_vue_2/
                // NOTE: if you don't provide 'selected' option here, then the form
                // builder adds the 'selected' attribute to the first option.
                'selected' => [],
                'empty_value' => 'Please select a prop'
            ])
kristijanhusak commented 7 years ago

@lsmith77 did you try setting it to null or false ?

lsmith77 commented 7 years ago

yes

kristijanhusak commented 7 years ago

Are you binding any model to the form, or it's empty?