It’s nothing specific to CMB2, but you could pass in the a maxlength attribute to be appended to the field input. https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
Thanks!
Marking as resolved
Hey Michael,
Just wondering – how would I go about passing the maxlength attribute to be appended to the field input? Not sure where to start.
Thanks!
ogdsgn, this will work on text inputs, despite the example being a textarea.
$cmb->add_field( array(
'name' => 'Extra Small Textarea',
'id' => 'wiki_test_xtra_small_textarea',
'type' => 'textarea_small',
'attributes' => array(
'placeholder' => 'A small amount of text',
'rows' => 3,
'required' => 'required',
),
) );
Note the “attributes” portion. You can add extra html attributes to ANY of the field types like this, including maxlengh.