Custom Fields
Re-Envisioned
Support Meta Box Conditional Logic How to hide group field when post field is empty?

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 1 year, 8 months ago.

  • Creator
    Topic
  • #8391
    Resolved
    fexy
    Participant

    Hello,

    What is the syntax for hiding a (group) field when another field (type=’post’) is null?

    I’ve tried several different variations like this on my group field:

    'hidden' => array('post', '!=', null),

    where ‘post’ is the metabox id of a sibling field. e.g.:

    array(
    'name' => __('Post'),
    'id' => 'post',
    'type' => 'post',
    'field_type' => 'select_advanced',
    'post_type' => array('recipe', 'post'),
    'placeholder' => 'Select post',
    'desc' => 'A recipe or post that appears in the list.'
    ),
Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #8409

    Anh Tran
    Keymaster

    Hi, the problem is your post field ID. On the editing screen, the #post is used for the post form, so you can’t use ID post. You need to change the ID of the post field.

    Then, you can hide the group if the field is null with this condition:

    'hidden' => array( 'post2', '=', '' ), // post2 is post field ID.

    PS: Please renew your license to get updates of extensions and support.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.