Hi there!
Just wanted to ask if Metabox validation works okay with the MB Settings Page extension? I use the exact same example validation code for a simple text field (required and minlength) and it works perfectly fine in a post metabox but not on the settings page.
The only thing that appears on the settings page is the red "asterix" next to the field label so it actually DOES something there but I can leave the text field empty or type a smaller amount of characters than one set in the minlength and can save the settings page without any problem.
As I said: the code works perfectly fine in the post metabox.
Here is the settings page code:
$meta_boxes[] = array(
'id' => 'configuration',
'title' => 'API',
'settings_pages' => 'test-plugin-settings',
'tab' => 'configuration',
'fields' => array(
array(
'name' => __( 'API key', 'kashing' ),
'id' => 'api_key',
'type' => 'text',
),
),
'validation' => array(
'rules' => array(
'api_key' => array(
'required' => true,
'minlength' => 7,
),
),
// Optional override of default error messages
'messages' => array(
'api_key' => array(
'required' => __( 'API Key is required', 'kashing' ),
'minlength' => __( 'Password must be at least 7 characters', 'kashing' ),
),
)
)
);