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

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

Supports all input types: text, number, email, url, color, range, hidden, password, datetime, time, datetime-local, week and any other supported by browsers. See list

Usage

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

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

                            'my_text' => [

                                // By default, the addon will set field type "input" and control type "text"

                                'title' => __( 'My text', 'my-domain' ),
                            ],

                            'my_email' => [
                                'type' => 'input',
                                'title' => __( 'Email address', 'my-domain' ),
                                'control' => [
                                    'type' => 'email',
                                    'wide' => true,
                                    'attributes' => [
                                        'placeholder' => __( 'Type and email', 'my-domain' ),
                                        'style' => 'background:#ccc;',
                                        'disabled' => 'disabled',
                                    ],
                                ],
                            ],

                            'price' => [
                                'type' => 'input',
                                'title' => __( 'Price', 'my-domain' ),
                                'control' => [
                                    'type' => 'number',
                                    'attributes' => [
                                        'min' => 0,
                                        'max' => 999999,
                                        'step' => '.1',
                                    ],
                                ],
                            ],

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

Control options

Control Data type Description
type string Supported input type: text, number, email, url, color, range, hidden, password, datetime, time, datetime-local, week and any other supported by browsers.
wide bool Flag that indicates if the input should display wider or small.
autocomplete bool HTML autocomplete option. Default: false
attributes array HTML attributes listed as an array.
⚠️ **GitHub.com Fallback** ⚠️