Control: Select - 10quality/wpmvc-addon-metaboxer GitHub Wiki

Control used as a field type to display an HTML <select>.

Usage

class Post extends Model
{
    // Class properties and methods...

    protected function init()
    {
        $this->metaboxes = [
            'metabox_id' => [
                'tabs' => [
                    'tab_id' => [
                        'fields' => [

                            'my_select' => [
                                'type' => 'select',
                                'title' => __( 'My select', 'my-domain' ),
                                'default' => 'b',
                                'options' => [
                                    'a' => __( 'Option A', 'my-domain' ),
                                    'b' => __( 'Option B', 'my-domain' ),
                                    'c' => __( 'Option C', 'my-domain' ),
                                ],
                            ],

                            'auth' => [
                                'type' => 'select',
                                'title' => __( 'Authentication', 'my-domain' ),
                                'description' => __( 'Select description.', 'my-domain' ),
                                'options' => [
                                    'basic' => __( 'Basic', 'my-domain' ),
                                    'oauth' => __( 'OAuth', 'my-domain' ),
                                ],
                                'control' => [
                                    'wide' => true,
                                    'add_empty' => true,
                                    'empty_label' => __( '- No auth -', 'my-domain' ),
                                ],
                            ],

                            // Other fields...
                        ],
                    ],
                ],
            ],
        ];
    }
}

Control options

Control Data type Description
wide bool Flag that indicates if the input should display wider or small. Default: false
add_empty bool Flag that indicates if an empty option should be added. Default: false
empty_label string Empty option label. Default: ``
⚠️ **GitHub.com Fallback** ⚠️