carbon-fields icon indicating copy to clipboard operation
carbon-fields copied to clipboard

"Conditional logic" removes the input value from the database

Open siaeb opened this issue 3 years ago • 1 comments

Version

  • Carbon Fields: 3.3
  • WordPress: 5.9.3
  • PHP: 7.1

Expected Behavior

When an input control depends on a checkbox control (through Conditional Logic), its value should not be deleted

Actual Behavior

For example, if a control textarea is dependent on a control checkbox (through Conditional Logic) by disabling the checkbox control, the value of the textarea is deleted and nothing saved into the database ( the value will be empty and reset)

Container definition

Container::make( 'theme_options', 'Custom Carbon Fields' )->add_fields( [
			Field::make( 'checkbox', 'crb_checkbox_field', 'Sample Checkbox' ),
			Field::make('textarea', 'crb_textarea_field', 'TextArea')->set_conditional_logic([
				[
					'field' => 'crb_checkbox_field',
					'value' => true,
				],
			])
		]);

Steps to Reproduce the Problem

  1. Check the checkbox
  2. Enter some test value into the textarea input or text input
  3. Save changes
  4. Uncheck the checkbox
  5. Save changes
  6. The value we previously entered for the text box will be deleted!

siaeb avatar Apr 15 '22 04:04 siaeb

I guess this isn't going to be fixed anytime soon.

jordantrizz avatar Feb 26 '25 01:02 jordantrizz