Support › MB Custom Post Type › Form Validation Not Working in Custom Post TypeResolved
This is My Code.
'id' => $prefix . 'name',
'type' => 'text',
'name' => esc_html__( 'Name', 'text-domain' ),
'tab' => 'personal_information',
'required' => true
And I am Used Validation Rules also,
'validation' => array(
'rules' => array(
'name' => array(
'required' => true,
'minlength' => 7
'messages' => array(
'field_id' => array(
'required' => 'Name is required',
'minlength' => 'Name must be at least 7 characters',
Whats is the problem.the same code worked for me in Meta Box Old Version.
As your field has $prefix, you need to set the ID $prefix . 'name' in your validation rules.
$prefix . 'name'
I am sure that's not a issue. because i set a $prefix value is empty.
here my code,
$prefix = '';
Are you using Gutenberg? The validation doesn't work for Gutenberg yet because Gutenberg doesn't have a way to check the values before submission via Ajax.
Yes I am using new Gutenberg Editor. Is there any solution for this.
Thanks in Advance.
I'm afraid there's no solution for it yet. Gutenberg seems to have bad support for live validation. Here are several issues opened on Gutenberg's Github repo:
Thanks for your help Tran.