Open Ryvix opened 3 years ago
I have the same problem within complex fields within a block. Have you found a solution to this?
I don't believe I have. Although I haven't tested it lately to find out if it was fixed in the latest update but sounds like it isn't.
Using Carbon Fields latest v3.3.0, conditional logic does seem to work 90% for me but there is an error being thrown and page functionality breaking when deleting the block.
Sample code:
Block::make(__('Testing Block'))
->add_fields([
Field::make('text', 'title', __('Title')),
Field::make('checkbox', 'option', __('Option?')),
Field::make('text', 'content', __('Text Content'))
->set_conditional_logic( array(
array(
'field' => 'option',
'value' => true,
)
) ),
])
->set_render_callback(function() {});
When using this sample code, I am able to create the block and use it, and conditional logic works normally. However, when I delete the block, this error is thrown and the page does not update properly after the block has been deleted:
blocks.min.js?ver=3.3.0:11 Uncaught (in promise) TypeError: Cannot read property 'attributes' of null
at blocks.min.js?ver=3.3.0:11
at blocks.min.js?ver=3.3.0:11
at blocks.min.js?ver=3.3.0:11
at core.min.js?ver=3.3.0:47
at data.min.js?ver=943087ae96d075f126df689839bb96b9:2
at Array.forEach (<anonymous>)
at i (data.min.js?ver=943087ae96d075f126df689839bb96b9:2)
at data.min.js?ver=943087ae96d075f126df689839bb96b9:2
at p (data.min.js?ver=943087ae96d075f126df689839bb96b9:2)
at redux-routine.min.js?ver=284288e957394d2097c6fbe95625e2fb:2
Which points to this line of the minified file:
Which I believe I narrowed down to being this line of code
That's as far as I got, hope it is helpful in debugging this.
Version
Expected Behavior
Conditional field should remain hidden when setting as a reusable block.
Actual Behavior
Hidden fields are no longer hidden when using a reusable block.
Container definition
Steps to Reproduce the Problem
Comments
I don't know why this would be an intended behaviour so I figure it must be a bug.
May be related to issue #800