Closed nickcernis closed 9 years ago
Fieldmanager has a similar display_if
attribute. The logic is such that the field will display if the value of another field is N.
The aim as far as plugins are concerned is not to replace plugins like ACF - it's to enable those plugins that provide more complex UI and/or UI builders for fields to use a common API. The project in its current status is rightfully focusing on the PHP side of the API, and I would not endorse the inclusion of this functionality via UI in core itself.
Definitely what I was about to say @helenhousandi :)
I will make every effort to ensure something like this will be easy to hook into for plugin purposes though, so anyone with a vested interest feel free to follow up on this.
Just to clarify, in the above comments at least two types of visibility dependencies are discussed. ACF discerns the two as Custom location rules
and Conditional Logic
.
Drawing a parallel between ACF and WP Fields API I think the first would apply to
$wp_fields->add_section
, while the second would apply to $wp_fields->add_field
.
Custom location rules are discussed above by @nickcernis. In addition, Conditional Logic works based on the values of 'sibling' fields (i.e. fields that are in the same section).
References: http://www.advancedcustomfields.com/resources/custom-location-rules http://www.advancedcustomfields.com/resources/field-settings/ (it appears little documentation is available for ACFs Conditional Logic)
Thanks for the feedback, @helenhousandi and @sc0ttkclark!
To clarify, I wasn't proposing that this be added via a new UI – I was suggesting that it be possible without a lot of additional code via the new API.
Then request granted :)
Advanced Custom Fields and similar plugins offer rules for meta box visibility such as these:
This is very powerful because it allows the creation of meta boxes that:
To accomplish this, there are a couple of approaches we could take:
add_field
andadd_section
methods take an optional array instead of the default string, which would allow users to specify in more detail exactly where fields and sections appear.I appreciate that the Fields API may not be a complete functional replacement for ACF. But if it's to become widely adopted and loved by all, it probably needs to take on some of the more advanced functionality that developers are currently gaining from third-party plugins.