cmb2-conditionals icon indicating copy to clipboard operation
cmb2-conditionals copied to clipboard

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

Open Jnspg opened this issue 9 years ago • 1 comments

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?

Jnspg avatar Dec 26 '16 00:12 Jnspg

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

fakeartist avatar Mar 30 '17 13:03 fakeartist