carbon-fields
carbon-fields copied to clipboard
Multiple entries of complex field containing radio field have unexpected behavior
Version
- Carbon Fields: 3.1.20
- WordPress: 5.5.1
- PHP: 7.4.3
Expected Behavior
I expect to be able to set individual Target Type radio field options for each entry in the complex field group without affecting the other entries.
Actual Behavior
Selecting an option in one entry for the block will alter the instances of the target_type field in other entries.
Steps to Reproduce the Problem
- Add the block code attached below.
- Add one instance of this block to one post or page.
- Add multiple entries to the hero block.
- Set the
target_typeof the first entry to one of the available values, e.g. click on Internal and the button is now sahded blue. - Go to the second entry and select an option for the
target_type. The second entry'starget_typeoption will now be shaded blue and thetarget_typeoption for entry one is now no longer shaded blue and it appears that the entry is cleared.
Comments
Block::make( __( 'Hero', 'td') )
->add_fields( array(
Field::make( 'complex', 'hero_items', __( 'Items', 'td' ) )
->add_fields( array(
Field::make( 'image', 'image', __( 'Image', 'td' ) )
->set_help_text( __( '1600px by 900px minimum', 'td' ) ),
Field::make( 'text', 'heading', __( 'Heading', 'td' ) ),
Field::make( 'rich_text', 'text', __( 'Text', 'td' ) ),
Field::make( 'radio', 'target_type', __( 'Target Type' ) )
->add_options( array(
0 => __( 'Internal', 'td' ),
1 => __( 'External', 'td' ),
) ),
Field::make( 'association', 'internal_item', __( 'Internal Item', 'td' ) )
->set_max( 1 )
->set_conditional_logic( array(
array(
'field' => 'target_type' ,
'value' => 0,
),
) )
->set_types( array(
array(
'type' => 'post',
'post_type' => 'post'
),
array(
'type' => 'post',
'post_type' => 'page'
),
) ),
Field::make( 'text', 'external_url', __( 'External URL', 'td' ) )
->set_conditional_logic( array(
array(
'field' => 'target_type' ,
'value' => 1,
),
) ),
) )
) )
->set_render_callback( array( __CLASS__, 'render_block_hero' ) );
}
Hello, clubdeuce
We managed to reproduce the problem and started working on a fix.
Thank you, @Panchev.
update?