jon-b
9/3/2014 - 9:22 PM

CMB2 Number Field

CMB2 Number Field

<?php

$cmb->add_field( array(
	'name' => __( 'Postive numbers', 'theme-domain' ),
	'desc' => __( 'Numbers only', 'msft-newscenter' ),
	'id'   => $prefix . 'number',
	'type' => 'text',
	'attributes' => array(
		'type' => 'number',
		'pattern' => '\d*',
	),
	'sanitization_cb' => 'absint',
        'escape_cb'       => 'absint',
) );

$cmb->add_field( array(
	'name' => __( 'Numbers', 'theme-domain' ),
	'desc' => __( 'Numbers only', 'msft-newscenter' ),
	'id'   => $prefix . 'number',
	'type' => 'text',
	'attributes' => array(
		'type' => 'number',
		'pattern' => '\d*',
	),
	'sanitization_cb' => 'intval',
        'escape_cb'       => 'intval',
) );