Support

Account

Home Forums Add-ons Repeater Field Conditional on Repeater, after save post

Solving

Conditional on Repeater, after save post

  • I have a problem with using repeater with conditional fields, everything works fine until I save the post, but when editing the post the conditional fields do not follow the condition they should.

    I use this for test:

    if( function_exists('acf_add_local_field_group') ):
    
    acf_add_local_field_group(array(
    	'key' => 'group_5bca5488b5583',
    	'title' => 'teste',
    	'fields' => array(
    		array(
    			'key' => 'field_5bca5511b1fd5',
    			'label' => 'repetidor',
    			'name' => 'repetidor',
    			'type' => 'repeater',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'collapsed' => '',
    			'min' => 0,
    			'max' => 0,
    			'layout' => 'table',
    			'button_label' => '',
    			'sub_fields' => array(
    				array(
    					'key' => 'field_5bca5491301e8',
    					'label' => 'teste',
    					'name' => 'teste',
    					'type' => 'select',
    					'instructions' => '',
    					'required' => 0,
    					'conditional_logic' => 0,
    					'wrapper' => array(
    						'width' => '',
    						'class' => '',
    						'id' => '',
    					),
    					'choices' => array(
    						'LIGADO' => 'LIGADO',
    						'DESLIGADO' => 'DESLIGADO',
    					),
    					'default_value' => array(
    					),
    					'allow_null' => 0,
    					'multiple' => 0,
    					'ui' => 1,
    					'ajax' => 1,
    					'return_format' => 'value',
    					'placeholder' => '',
    				),
    				array(
    					'key' => 'field_5bca54bf301e9',
    					'label' => 'LIGADO',
    					'name' => 'ligado',
    					'type' => 'text',
    					'instructions' => '',
    					'required' => 0,
    					'conditional_logic' => array(
    						array(
    							array(
    								'field' => 'field_5bca5491301e8',
    								'operator' => '==',
    								'value' => 'LIGADO',
    							),
    						),
    					),
    					'wrapper' => array(
    						'width' => '',
    						'class' => '',
    						'id' => '',
    					),
    					'default_value' => '',
    					'placeholder' => '',
    					'prepend' => '',
    					'append' => '',
    					'maxlength' => '',
    				),
    				array(
    					'key' => 'field_5bca54d0301ea',
    					'label' => 'DESLIGADO',
    					'name' => 'desligado',
    					'type' => 'text',
    					'instructions' => '',
    					'required' => 0,
    					'conditional_logic' => array(
    						array(
    							array(
    								'field' => 'field_5bca5491301e8',
    								'operator' => '==',
    								'value' => 'DESLIGADO',
    							),
    						),
    					),
    					'wrapper' => array(
    						'width' => '',
    						'class' => '',
    						'id' => '',
    					),
    					'default_value' => '',
    					'placeholder' => '',
    					'prepend' => '',
    					'append' => '',
    					'maxlength' => '',
    				),
    			),
    		),
    	),
    	'location' => array(
    		array(
    			array(
    				'param' => 'post_type',
    				'operator' => '==',
    				'value' => 'teste',
    			),
    		),
    	),
    	'menu_order' => 0,
    	'position' => 'normal',
    	'style' => 'default',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => '',
    	'active' => 1,
    	'description' => '',
    ));
    
    endif;
  • I just did a test with something similar and I’m not seeing any issue. Can you give a better explanation of ...but when editing the post the conditional fields do not follow the condition they should.

  • When adding a new post, logical conditionals work, after saving the post the conditional logic does not work.

    This problem only happens on conditional fields inside of repeater and after save a post.

  • That is what you said in your OP. I have tested this and I’m not seeing any issues. Everything is working as I expect it to.

    Please give more information and details on what you mean by “does not work correctly”

  • Before save the post, it is working correctly:
    Repeater-before-save

    After save or edit post, does not work correctly:
    After-save-post

    How you see, after save the post the ONLY input that should appear is the ONE chosen (ON or OFF picked), but the two options ever happening

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Conditional on Repeater, after save post’ is closed to new replies.