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

Multiple attributes doesn't take first data-conditional-value into account #35

Open
Jnspg opened this issue Dec 26, 2016 · 1 comment
Open

Comments

@Jnspg
Copy link

Jnspg commented Dec 26, 2016

Hello,

First of all, thank you very much for all the work you've put into this plugin, and for the help you might be able to provide.

I've created 2 radio fields and I would like a field appear according to the combo of options.

$cmb->add_field( array(
	'name' => __( 'Format', 'cw' ),
	'id' => $prefix . 'format-radio',
	'type' => 'radio_inline',
	'options' => array(
		'file' => __( 'upload file', 'cw' ),
		'link' => __( 'insert a link', 'cw' ),
	),
) );
$cmb->add_field( array(
	'name' => __( 'Type', 'cw' ),
	'id' => $prefix . 'type-radio',
	'type' => 'taxonomy_radio_inline',
	'taxonomy' => 'news_type',
'show_option_none' => false,
) );
$cmb->add_field( array(
	'name' => __( 'Video file', 'cw' ),
	'id' => $prefix . 'video_file',
	'type' => 'file',
'attributes' => array(
     'data-conditional-id' => $prefix . 'format-radio',
     'data-conditional-value' => 'file',
),
'attributes' => array(
     'data-conditional-id' => $prefix . 'type-radio',
     'data-conditional-value' => 'video',
),
) );
$cmb->add_field( array(
	'name' => __( 'Video link', 'cw' ),
	'id' => $prefix . 'video_link',
	'type' => 'text_url',
'attributes' => array(
     'data-conditional-id' => $prefix . 'format-radio',
     'data-conditional-value' => 'link',
),
'attributes' => array(
     'data-conditional-id' => $prefix . 'type-radio',
     'data-conditional-value' => 'video',
),
) );

But only the data-conditional-value ('video') of the second attributes is taken into account, the first one ('link' or 'file') is not. As a result, the two field appears if 'video' is checked, it doesn't matter which option is checked in the first radio. I would like the file type field to appear if both options 'file' & 'video' are checked, and the url type field to appear if both options 'link' & 'video' are checked.

Could you help me?

@fakeartist
Copy link

Same here. Would be great if we could add an AND or OR combination of attributes.

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

2 participants