Here is a part of the CMB2 registration:
$prefix = '_wdtv_fiets_route_';
// Initiates the metabox
$cmb = new_cmb2_box( array(
'id' => 'fiets_routes_data',
'title' => __( 'Fiets routes informatie', 'cmb2' ),
'object_types' => array( 'fiets_routes' ),
'context' => 'advanced',
'priority' => 'high',
'show_names' => true, // show field names on the left
// 'cmb_styles' => false, // false to disable the CMB stylesheet
// 'closed' => true, // keep the meatabox closed by default
) );
/**
* Creates the fields to go with the custom metabox
*/
// small text area field for route description
$cmb->add_field( array(
'name' => 'Route beschrijving',
'desc' => 'Geef hier een korte beschrijving van de route',
'id' => $prefix . 'beschrijving_textareasmall',
'type' => 'textarea_small',
'attributes' => array(
'required' => 'required',
),
));
// small text field for route distance
$cmb->add_field( array(
'name' => 'Lengte route',
'after_field' => ' <b>km</b> <span class="cmb2-metabox-description"> De (globale) lengte van de route</span>',
'id' => $prefix . 'afstand_textsmall',
'type' => 'text_small',
'attributes' => array(
'type' => 'number',
'required' => 'required',
),
));
The ‘Lengte route’ part is supposed to be numbers only. It shows arrow up and down in the inputfield that produces a number, but you’re still able to type text in the field. Any thoughts on that?
Thanks in advance,
Bert.