mustardBees / cmb-field-select2

Select2 field type for Custom Metaboxes and Fields for WordPress
93 stars 46 forks source link

Not able To create blank as default value #36

Closed jeni1616 closed 7 years ago

jeni1616 commented 7 years ago

Thank you for this great plugin , i tried messing with custom code like allowClear: true, placeholder: {id: "-1",}

but no matter what when i update post , it just take first value of array as default , i want to keep it blank , but it's selecting to first value of array as default value , is there any option i can set blank field till user not select anything manually ?

Thanks .

jeni1616 commented 7 years ago

i also tried this when creating field :

'attributes' => array( 'data-allowClear' => true, 'data-placeholder--text' => 'sme', 'data-placeholder--id' => '-1', ),

but throwing error in console : Cannot use 'in' operator to search for 'text' in and select2 also stop work after that .

Thanks.

jeni1616 commented 7 years ago

don't know why but it's working now without any change ! 😀 may be issue was in my array itself , i just made first entry with value -1 . Thank you .

mustardBees commented 7 years ago

@jeni1616 Glad you got this sorted.