mustardBees / cmb-field-select2

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

Versions > 2.2.2 require initiation of a type object #34

Closed jtsternberg closed 8 years ago

jtsternberg commented 8 years ago

The type object is needs to be initiated and added to the types object in order for some of the methods to work (like concat_items). This ensures it will work in the future while also still working for older versions of CMB2.

jtsternberg commented 8 years ago

To be clear, a Type object should be initiated which is related to the field type you are using. Which in your case is the CMB2_Type_Select type. Types can be found here: https://github.com/WebDevStudios/CMB2/tree/master/includes/types and they are initiated here: https://github.com/WebDevStudios/CMB2/blob/master/includes/CMB2_Types.php#L336-L509

(Just documenting for the future)

jtsternberg commented 8 years ago

To try and address some back-compatibility issues, I've put in a shim: https://github.com/WebDevStudios/CMB2/commit/c6e933127681e79b5769224220ea438240d75df9. Notice, it will still throw a _doing_it_wrong notice, so this change in the PR is still required.

boneus commented 8 years ago

But there is still a problem: concat_items doesn't add checked attribute to options, because there is no value in CMB2_Type_Select object at the moment. For now I've added my own method which concatenates options list but wondering if there is a better solution. I've tried to initiate types object with value passed as argument, but it doesn't show up.