acf-builder icon indicating copy to clipboard operation
acf-builder copied to clipboard

New conditionals with only two parameters.

Open christianmagill opened this issue 6 years ago • 4 comments

@stevep,

ACF 5.7 brings with it new field conditionals that only have two parameters.

Unfortunately, ACF Builder doesn't allow conditions with two parameters.

I've tried passing null but while it successfully builds, it stops the validation from working properly in certain scenarios.

Unfortunately this is causing a breaking issue for me.

The two conditionals in question are "==empty" and "!=empty".

Here's an example of how the fields output through the generate PHP option in ACF.

'conditional_logic' => array(
				array(
					array(
						'field' => 'field_5b1305029be7d',
						'operator' => '>',
						'value' => '6.4999999',
					),
					array(
						'field' => 'field_5b1305029be7d',
						'operator' => '<',
						'value' => '8.5000000',
					),
					array(
						'field' => 'field_5b1305029be7d',
						'operator' => '!=empty',
					),
				),
			),

christianmagill avatar Jun 03 '18 19:06 christianmagill

Finally going to implement this, it seems that basically we should make the value parameter optional(?)

stevep avatar Jan 12 '20 22:01 stevep

^ yep

Log1x avatar Jan 13 '20 05:01 Log1x

Any word on this? Would like to implement this!

Levdbas avatar May 17 '21 06:05 Levdbas

For anyone looking to do this, it seems to work if you set the third parameter to an empty string or false

E.g. ->conditional('field_name', '!=empty', false);

thunderdw avatar Jun 13 '22 18:06 thunderdw