• Jer Clarke

    (@jeremyclarke)


    Hey man, noticed another behavior that is strange to me and probably confuses people if they see it: Any fields added to a group will show on all objects the group is on, even if the list of objects the field is added to are not the same.

    I.e. If you add a group with $object_types=array(‘page’, ‘post’), then add fields to the group but only for ‘page’ then all those fields will still show on the post edit screen.

    EXAMPLE

    I added a general group named after my site/plugin that I wanted to use on both posts and pages, as a result I used this code:

    x_add_metadata_group('gv_custom_metadata_posts', array('page', 'post'), array(
    		'label' => 'GV Custom Metadata',
    		'priority' => 'high',
    	));

    I then added fields to the metabox, assigning them only to post or page objects:

    `x_add_metadata_field(‘page-excerpt’, array( ‘page’), array(
    ‘group’ => ‘gv_custom_metadata_posts’,
    ‘label’ => ‘Optional Page Excerpt’,
    ‘field_type’ => ‘textarea’,
    ));
    x_add_metadata_field(‘gv-extra-wide’, array( ‘post’), array(
    ‘group’ => ‘gv_custom_metadata_posts’,
    ‘label’ => ‘Full-width content (hide sidebar and fill space with content)’,
    ‘field_type’ => ‘checkbox’,
    ));`

    The result I’d expect is that the group metabox details are the same on both edit screens, but that only the fields assigned to each specific screen would show.

    What happened instead was that both fields showed in both edit screens. This effectively means that if a field is in a group, the group’s $object_types completely override those set in the field registration.

    IMHO this is confusing and not really desirable behavior. I think the use-case of wanting one metabox with variable contents is a common one for plugin/theme devs and a lot of people might not notice that there were settings on one context that they had tried to not show there (which would in turn confuse users if the related theme feature wasn’t set up on the object in question).

    Thanks for looking into this, hopefully it’s not too hard to manage. If you don’t think this behavior should change then I’d recommend goign through the documentation and mentioning it a couple of times so people know that they should never use a group on more than one object_type unless they want it to have the exact same fields.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Jer Clarke

    (@jeremyclarke)

    Forgot to hit subscribe button, ignore this post 🙂

    Plugin Author Mohammad Jangda

    (@batmoo)

    The result I’d expect is that the group metabox details are the same on both edit screens, but that only the fields assigned to each specific screen would show.

    Agreed, that sounds like a bug to me. I’ll try to get it fixed soon.

    Plugin Author Joey Kudish

    (@jkudish)

    Did we ever solve this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Custom Metadata Manager] fields in group show on all post types set for group, even if not’ is closed to new replies.