Tagged: add_more, conditions, groups
- This topic has 5 replies, 2 voices, and was last updated 7 years, 3 months ago by
Steve.
-
AuthorPosts
-
-
November 4, 2014 at 6:33 am #2641
atanasMemberHi,
Thanks a lot for the work you guys have put into this project.
I am trying to have conditions in add more groups based on select fields (two of them per group). For example if the user selects an entry in the first select list, then I would like to show the appropriate child select list (its a basic parent/child relationship between the first and second select).
In the current version, changing the selected value in one of the add more groups, updates all the select fields ln the other add more groups.
Is there any other way to display such groups, or any suggested workaround
Thanks
Atanas -
November 4, 2014 at 12:00 pm #2648
-
November 4, 2014 at 1:41 pm #2653
atanasMemberHi Steve,
Here is the code that demonstrates both the conditions in add more (if you have more than one addmore, selecting a fruit in one of them will force display the corresponding fruits in all of the add mores) and the misalignment when trying to put all the fields in one group (besides the conditions do not work when in a sub-group)
piklist('field', array('type' => 'group', 'label' => 'Settings', "field" => "settings", 'description' => 'Main Settings Field', 'add_more' => false, 'fields' => array( array('type' => 'group', 'label' => 'Fruits', 'add_more' => true, 'description' => 'Select a fruit.', 'fields' => array( array( 'type' => 'select', 'field' => 'country', 'label' => 'Country', 'value' => 'US', 'columns' => 4, 'choices' => array( 'US' => 'United States', 'EU' => 'European Union' ) ), array( 'type' => 'select', 'field' => 'fruits', 'label' => 'Fruits', 'value' => 'apples', 'columns' => 12, 'choices' => array( "apples" => "Apples", "oranges" => "Oranges", ) ), array( 'type' => 'select', 'field' => 'apples', 'label' => 'Apples', 'columns' => 12, 'value' => 'post_title', 'choices' => array( "aceymac" => 'Aceymac apple', "akero" => 'Akero apple', ), 'conditions' => array( array( "reset" => false, 'field' => 'fruits', 'value' => "apples" ), )), array( 'type' => 'select', 'field' => 'oranges', 'label' => 'Oranges', 'columns' => 12, 'choices' => array( "blood" => "Blood Orange", "navel" => "Navel Orange" ), 'conditions' => array( array( "reset" => false, 'field' => 'fruits', 'value' => "oranges" ), )), ), ), array( 'type' => 'select', 'field' => 'shipping', 'label' => 'Shipping', 'columns' => 4, 'choices' => array( '' => '', 'ground' => 'Ground', 'UPS' => 'UPS', ) ), ), ) ); -
November 5, 2014 at 12:12 pm #2658
-
November 5, 2014 at 1:59 pm #2661
atanasMemberHi steve,
In the add more are the fields:
Country – a select field
Fruits – a select field
Organges and apples – select fields with a condition based on the above fruits field ( is user selects organges as the fruit, we show the varieties of organges, if they select apples, we show the varieties of apples)Outside of the add more is the shipping field
Thanks
Atanas -
November 6, 2014 at 1:42 pm #2662
SteveKeymaster@atana– It was really tough to debug your code so I just wrote it from scratch. I also attached a screenshot so you can see what it should look like. Let me know if this works for you.
piklist('field', array( 'type' => 'group' ,'field' => 'atanas_settings' ,'label' => __('Settings') ,'add_more' => true ,'fields' => array( array( 'type' => 'select' ,'field' => 'country' ,'label' => 'Country' ,'columns' => 12 ,'choices' => array( 'US' => 'United States' ,'EU' => 'European Union' ) ) ,array( 'type' => 'select' ,'field' => 'fruits' ,'label' => 'Fruits' ,'columns' => 12 ,'choices' => array( 'apples' => 'Apples' ,'oranges' => 'Oranges' ) ) ,array( 'type' => 'select' ,'field' => 'apples' ,'label' => 'Apples' ,'columns' => 12 ,'choices' => array( 'aceymac' => 'Aceymac Apple' ,'akero' => 'Akero Apple' ) ,'conditions' => array( array( 'field' => 'atanas_settings:fruits' ,'value' => 'apples' ) ) ) ,array( 'type' => 'select' ,'field' => 'oranges' ,'label' => 'Oranges' ,'columns' => 12 ,'choices' => array( 'blood' => 'Blood Orange' ,'navel' => 'Navel Orange' ) ,'conditions' => array( array( 'field' => 'atanas_settings:fruits' ,'value' => 'oranges' ) ) ) ) )); piklist('field', array( 'type' => 'select' ,'field' => 'shipping' ,'label' => 'Shipping' ,'choices' => array( 'ground' => 'Ground' ,'ups' => 'UPS' ) ));Attachments:
You must be logged in to view attached files.
-
-
AuthorPosts
- The topic ‘Conditions in add more groups’ is closed to new replies.