Nested conditional logic leads to incorrect validation of required fields

Support MB Conditional Logic Nested conditional logic leads to incorrect validation of required fields

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #39951
    SIWSIW
    Participant

    In some cases a group field is hidden by conditions but still validated and blocking saving when empty.

    Create
    - checkbox a
    - group b with 2 fields
    -- checkbox c
    -- text field d (required)

    Make group b visible if checkbox a = true
    Make text field d visible when checkbox c is true.

    In the following two situation the text field is not visible but still required

    1. Check checkbox a and uncheck checkbox c
    2. Check checkbox a, check checkbox c and then uncheck checkbox a

    #39966
    PeterPeter
    Moderator

    Hello,

    I've tested your case and see that:

    1. checked A and checked C => error, D is required

    2. checked A and checked C then unchecked A => no error, post is still saved

    Can you please check the case 2 and let me know if it works on your side?

    #40015
    SIWSIW
    Participant

    Hi Peter,
    Thanks for your reply. You are right, scenario 2 indeed doesn't block saving.
    Scenario 1 still block saving when only checking checkbox A.

    For reference the meta box to reproduce the problem:

    
    $meta_boxes[] = [
    	'title'      => 'Conditional vibility',
    	'post_types' => 'post',
    	'fields'     => [
    		[
    			'name' => 'Checkbox A',
    			'id'   => 'checkboxA',
    			'type' => 'checkbox',
    		],
    		[
    			'id'      => 'group',
    			'type'    => 'group',
    			'visible' => [ 'checkboxA', true ],
    			'fields'  => [
    
    				[
    					'id'   => 'checkboxB',
    					'name' => __( 'Checkbox B', 'siw' ),
    					'type' => 'checkbox',
    				],
    				[
    					'id'       => 'text',
    					'name'     => __( 'Text', 'siw' ),
    					'type'     => 'text',
    					'visible'  => [ 'group_checkboxB', true ],
    					'required' => true,
    				],
    			],
    		],
    	],
    ];
    #40034
    PeterPeter
    Moderator

    Hi,

    Thanks for your feedback.

    I've escalated this issue to the development team to fix it in the next update. Let me know if you have any questions.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.