Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple on selectbox doesn't work #57

Open
jeffreyvr opened this issue Nov 4, 2014 · 0 comments
Open

Multiple on selectbox doesn't work #57

jeffreyvr opened this issue Nov 4, 2014 · 0 comments

Comments

@jeffreyvr
Copy link

When setting multiple on true (by types select and chosen), nothing happends. Here is a quick fix, it might not be perfect, but it does work.

Add this under line 19 in meta-boxe.php
$multiple = isset($field['multiple']) ? $field['multiple'] : null;

Then replace the code between line 67 and 75:

// select, chosen
case 'select':
case 'chosen':
    if(isset($multiple)) : // multiple
        echo '<select name="' . esc_attr($name) . '[]" multiple id="' . esc_attr($id) . '"', $type == 'chosen' ? ' class="chosen"' : '', '>';
        foreach ($options as $option) :
        if(is_array($meta) && in_array($option['value'], $meta)) :
                echo '<option selected value="' . $option['value'] . '">' . $option['label'] . '</option>';
            else :
            echo '<option value="' . $option['value'] . '">' . $option['label'] . '</option>';  
            endif;
        endforeach;
    echo '</select>';
    else : // normal select
        echo '<select name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '"' , $type == 'chosen' ? ' class="chosen"' : '' , isset( $multiple ) && $multiple == true ? ' multiple="multiple"' : '' , '>
        <option value="">Select One</option>'; // Select One    
        foreach ( $options as $option )    
            echo '<option' . selected( $meta, $option['value'], false ) . ' value="' . $option['value'] . '">' . $option['label'] . '</option>';    
            echo '</select><br />' . $desc;    
    endif;
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant