auxin-elements
/
admin
/
includes
/
compatibility
/
siteorigin
/
fields
/
select2-multiple.class.php
colorpicker.class.php
8 years ago
iconpicker.class.php
9 years ago
select2-multiple.class.php
8 years ago
visualselect.class.php
8 years ago
select2-multiple.class.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Class Auxin_SiteOrigin_Field_Select2 |
| 5 | */ |
| 6 | class Auxin_SiteOrigin_Field_Select2_Multiple extends SiteOrigin_Widget_Field_Base { |
| 7 | |
| 8 | protected $options; |
| 9 | |
| 10 | protected function render_field( $value, $instance ) { |
| 11 | |
| 12 | if( gettype( $value ) ==="string" ) { |
| 13 | $value = explode( ',', $value ); |
| 14 | } |
| 15 | |
| 16 | $output = '<div class="aux-element-field aux-multiple-selector ">'; |
| 17 | $output .= '<select multiple="multiple" name="'.$this->element_name.'" id="'.$this->element_id.'" style="width:100%" ' . ' class="wpb-multiselect wpb_vc_param_value aux-select2-multiple">'; |
| 18 | |
| 19 | foreach ( $this->options as $id => $option_info ) { |
| 20 | $active_attr = in_array( $id, $value ) ? 'selected="selected"' : ''; |
| 21 | $output .= sprintf( '<option value="%s" %s >%s</option>', $id, $active_attr, $option_info ); |
| 22 | } |
| 23 | |
| 24 | $output .= '</select></div>'; |
| 25 | |
| 26 | echo $output; |
| 27 | |
| 28 | } |
| 29 | |
| 30 | protected function sanitize_field_input( $value, $instance ) { |
| 31 | return $value; |
| 32 | } |
| 33 | } |
| 34 |