Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

required attribute not working #62

Open
jitmaity21 opened this issue Sep 10, 2018 · 0 comments
Open

required attribute not working #62

jitmaity21 opened this issue Sep 10, 2018 · 0 comments

Comments

@jitmaity21
Copy link

jitmaity21 commented Sep 10, 2018

$cmb->add_field( array(
	'name'    => __( 'Check', 'cmb2' ),
	'id'      => $prefix . 'type',
	'type'    => 'select',
	'options' => array(
		'type1' => __( 'Type 1', 'cmb2' ),
		'type2' => __( 'Type 2', 'cmb2' ),
		'type3' => __( 'Type 3', 'cmb2' ),
	),
	'attributes' => array(
		'required'            => true
	),
	'default' => 'type1',
) );

$cmb->add_field( array(
	'name'       => 'Thumbnail',
	'id'         => $prefix . 'thumb',
	'type'    => 'file',
	'options' => array(
		'url' => false,
	),
	'text'    => array(
		'add_upload_file_text' => 'Add Thumbnail'
	),
	'query_args' => array(
		'type' => array(
			'image/gif',
			'image/jpeg',
			'image/png',
		),
	),
	'preview_size' => 'thumbnail',
	'attributes' => array(
		'required'            => true,
		'data-conditional-id' => $prefix . 'type',
		'data-conditional-value' => wp_json_encode( array( 'type1', 'type2') ),
	),

) );

$cmb->add_field( array(
	'name'       => 'PDF',
	'id'         => $prefix . 'pdf',
	'type'    => 'file',
	'options' => array(
		'url' => false,
	),
	'text'    => array(
		'add_upload_file_text' => 'Add PDF'
	),
	'query_args' => array(
		'type' => 'application/pdf',
	),
	'attributes' => array(
		'required'            => true,
		'data-conditional-id'    => $prefix . 'type',
		'data-conditional-value' => 'type3',
	),
) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant