Show/Hide Dependant Fields Implementation
9 posts by 7 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: August 15, 2011 (RSS)
This one looks interesting, but I could use some more detailed implementation instructions.
Plus, what do I do with the CVS folder?
Hope you can find some time to help.
Thanks,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Show/Hide Dependant Fields Implementation
By Rusty - April 6, 2011 - edited: April 6, 2011
// For each section and list field, copy this block
// Fields will start hidden if they appear in any "fields to show" list
$GLOBALS['SHOWHIDE_DEPENDANT_FIELDS_CONFIG']['the_section_editor']['list_field_name'] = array(
// list option => fields to show
'' => array(), // show these fields when the topmost '<select>' option is selected
'List 1 - Opt 1' => array(),
'List 1 - Opt 2' => array(),
'List 1 - Opt 3' => array(),' => array('List 1', 'List 2'),
'_any_value_' => array('List 1'), // show these fields when a value not listed above is selected
);
Isn't altogether too intuitive. I understand the "my_section" and the "my_list_filed" however the array options is a bit confusing.
I want to make it so that if an option from a list is selected, that another, second list will be shown. But only if that option is selected, otherwise, it'd hide the second list.
Like this:
List 1 - Opt 1 (either 1 or 2 selected)
List 1 - Opt 2 (either 1 or 2 selected)
List 1 - Opt 3
=========== then IF....
List 1 - Opt 1
List 1 - Opt 2
List 1 - Opt 3 (3 selected)
With List 1 - Opt 3 selected then List 2 shows
List 2 - Opt 1
List 2 - Opt 2
List 2 - Opt 3
Re: [Rusty] Show/Hide Dependant Fields Implementation
By Mikey - April 7, 2011
Re: [zick] Show/Hide Dependant Fields Implementation
By robin - April 8, 2011
Looks like we need to improve the documentation for this plugin! In the meantime I've put together a little example that should hopefully help.
This example is from a school, where they store both teachers and students in the same section named "person", but they want different fields to show based on "person_type".
person_type is a list field in the "person" section with the options- "teacher" and "student.
The show hide setup would look something like this:
$GLOBALS['SHOWHIDE_DEPENDANT_FIELDS_CONFIG']['person']['person_type'] = array(
// list option => fields to show
'' => array('name'), // show these fields when the topmost '<select>' option is selected
'teacher' => array('name', 'degree', 'parking_space_number'),
'student' => array('name', 'grade', 'parent_contact_number'),
);
Hope that helps,
Robin
Programmer
interactivetools.com
Re: [robin] Show/Hide Dependant Fields Implementation
By gkornbluth - April 9, 2011
Makes more sense now.
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Show/Hide Dependant Fields Implementation
Here is how I have it structured.
$GLOBALS['SHOWHIDE_DEPENDANT_FIELDS_CONFIG']['person']['person_type'] = array(
// list option => fields to show
'' => array('name'), // show these fields when the topmost '<select>' option is selected
'kids' => array('kids'),
'parents' => array('parents', 'date'),
);
I have tables in the DB for kids, parents and person
Re: [Hybrid] Show/Hide Dependant Fields Implementation
By robin - April 15, 2011
Multi selects are not supported yet, I'll let Chris know there is demand!
In the meantime, I'm thinking based on your example you could do something like this:
Add an option called "Kids and Parents" in your menu, then in the code...
$GLOBALS['SHOWHIDE_DEPENDANT_FIELDS_CONFIG']['person']['person_type'] = array(
// list option => fields to show
'' => array('name'), // show these fields when the topmost '<select>' option is selected
'kids' => array('kids'),
'parents' => array('parents', 'date'),
'_any_value_' => array('kids', 'parents', 'date'), // show these fields when a value not listed above is selected
);
Hope that helps,
Robin
Programmer
interactivetools.com
Re: [robin] Show/Hide Dependant Fields Implementation
By Perchpole - May 31, 2011
I too have stumbled into an issue regarding this plugin and Multi-select menus.
Not being able to hide such fields renders the plugin fairly redundant for my particular project.
:0/
Perch
Re: [robin] Show/Hide Dependant Fields Implementation
By usadomains - August 15, 2011 - edited: August 15, 2011
Multi selects are not supported yet, I'll let Chris know there is demand! Ya, please get this updated to support this properly ... I can get it to work on the 1st list, but if I add additional ones for another field, they all show.