StoutLogic / acf-builder

An Advanced Custom Field Configuration Builder
GNU General Public License v2.0
792 stars 61 forks source link

New conditionals with only two parameters. #62

Open christianmagill opened 6 years ago

christianmagill commented 6 years ago

@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',
                    ),
                ),
            ),
stevep commented 4 years ago

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

Log1x commented 4 years ago

^ yep

Levdbas commented 3 years ago

Any word on this? Would like to implement this!

thunderdw commented 2 years ago

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);