- This topic has 4 replies, 2 voices, and was last updated 7 years, 2 months ago by
Steve.
-
AuthorPosts
-
-
December 8, 2014 at 2:00 pm #2997
egamipeaksMemberQuestion 1:
I am trying to recreate something similar to the location rules in Advanced Custom Fields (see screenshot), which would required nested groups with the ability to “add_more” on both.
The “add rule group” button would be the first level, and the “and” button on the side would be the second level.
Is this possible? I tried nesting groups and adding add_more to both levels but didn’t get it to work.
Question 2:
Is there built in functionality for populating select boxes via ajax based on another field?
Question 3:
Is there a way to customize the template of the “add_more” buttons
Thanks!
Attachments:
You must be logged in to view attached files. -
December 9, 2014 at 12:28 pm #3011
SteveKeymaster@egamipeaks– You can definitely get close to this.
1) Try starting with the code in
Piklist Demos > Add new Demo > Advanced > Content Section (Grouped) OR Content Section with Siblings (Grouped)2) You can’t populate Select Fields based on another field, but you can hide/show the select fields. You would generate all the select fields you need, but only show the one you want.
3) Currently there is no way to customize the add-more button.
We are happy to take a look at your code if you want.
-
December 9, 2014 at 3:01 pm #3016
egamipeaksMemberThanks for the help.
I have gotten further on the nested add more groups but have a couple of issues still.
The first is that I have to add more than one field in the nested group or the nested add more buttons don’t appear.
Also after creating several nested groups and saving, they all load into the first group in the UI. And if I try and remove groups and update they come back.
My code is below:
piklist(‘field’, array(
‘type’ => ‘group’,
‘label’ => ‘Location Rules’,
‘description’ => ‘Create a set of rules to determine which pages will load this Ad Unit’,
‘field’ => ‘_ad_unit_location_rules’,
‘add_more’ => true,
‘fields’ => array(
array(
‘type’ => ‘hidden’,
‘field’ => ‘location_desc’,
‘label’ => ”,
‘columns’ => 12,
‘value’ => ”
),
array(
‘type’ => ‘group’,
‘field’ => ‘location_group’,
‘add_more’ => true,
‘fields’ => array(
array(
‘type’ => ‘select’,
‘field’ => ‘location_page’,
‘label’ => ‘Page Condition’,
‘columns’ => 12,
‘choices’ => array(
‘post_type’ => “Post Type”,
‘page’ => “Page”,
‘page_type’ => “Page Type”,
‘page_parent’ => “Page Parent”,
‘page_template’ => “Page Template”,
‘post’ => “Post”,
‘post_category’ => “Post Category”,
‘taxonomy’ => “Post Taxonomy”,
‘ef_taxonomy’ => “Taxonomy Term”,
)
),
array(
‘type’ => ‘select’,
‘field’ => ‘location_comparison’,
‘label’ => ‘Comparison’,
‘columns’ => 12,
‘choices’ => array(
‘==’ => ‘Is equal to’,
‘!=’ => ‘Is not equal to’
)
),
array(
‘type’ => ‘select’,
‘field’ => ‘location_options’,
‘label’ => ‘Options’,
‘columns’ => 12,
‘choices’ => array(
‘op1’ => ‘option 1’,
‘op2’ => ‘option 2’
)
)
)
)
)
));That hidden field is only there so that it will display the second group of add more buttons.
-
December 11, 2014 at 11:11 am #3048
egamipeaksMemberFigured out my UI issue thanks
-
December 11, 2014 at 2:21 pm #3060
SteveKeymaster@egamipeaks– Awesome! Please post the final code when you are finished. We would love to see it.
-
-
AuthorPosts
- You must be logged in to reply to this topic.