Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
Show/Hide Dependant Fields Implementation

 

 


gkornbluth
Veteran

Feb 4, 2011, 4:00 PM

Post #1 of 9 (2276 views)
Shortcut
Show/Hide Dependant Fields Implementation Can't Post

Hi Chris,

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


Rusty
User

Apr 6, 2011, 4:36 AM

Post #2 of 9 (2076 views)
Shortcut
Re: [gkornbluth] Show/Hide Dependant Fields Implementation [In reply to] Can't Post

Yeah, I hear you there.


Code
// 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
Rusty


(This post was edited by Rusty on Apr 6, 2011, 5:00 AM)


zick
User

Apr 6, 2011, 10:30 PM

Post #3 of 9 (2041 views)
Shortcut
Re: [Rusty] Show/Hide Dependant Fields Implementation [In reply to] Can't Post

Have either of you figured out how to get this working? I can't seem to figure out what needs to be done so it will work.


robin
User / Moderator


Apr 8, 2011, 3:09 PM

Post #4 of 9 (2026 views)
Shortcut
Re: [zick] Show/Hide Dependant Fields Implementation [In reply to] Can't Post

Hey,

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:


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
'teacher' => array('name', 'degree', 'parking_space_number'),
'student' => array('name', 'grade', 'parent_contact_number'),
);


Hope that helps,
Robin


gkornbluth
Veteran

Apr 9, 2011, 6:05 AM

Post #5 of 9 (2019 views)
Shortcut
Re: [robin] Show/Hide Dependant Fields Implementation [In reply to] Can't Post

Thanks Robin,

Makes more sense now.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!
http://www.thecmsbcookbook.com


Hybrid
User

Apr 14, 2011, 2:50 AM

Post #6 of 9 (1962 views)
Shortcut
Re: [gkornbluth] Show/Hide Dependant Fields Implementation [In reply to] Can't Post

I've been getting this to work pretty well pulling tables its really cool but I see one limitation that I was curious if anyone could help with. Using single option pulldowns work however as soon as I try using multi select pulldowns or multi select checkboxes it breaks the show/hide and just displays them all. Is there perhaps something i'm missing?

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


robin
User / Moderator


Apr 15, 2011, 10:02 AM

Post #7 of 9 (1939 views)
Shortcut
Re: [Hybrid] Show/Hide Dependant Fields Implementation [In reply to] Can't Post

Hey Hybrid,

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...

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


Perchpole
User

May 31, 2011, 2:55 AM

Post #8 of 9 (1691 views)
Shortcut
Re: [robin] Show/Hide Dependant Fields Implementation [In reply to] Can't Post

Hi, Robin -

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


usadomains
Novice

Aug 15, 2011, 7:02 PM

Post #9 of 9 (1264 views)
Shortcut
Re: [robin] Show/Hide Dependant Fields Implementation [In reply to] Can't Post


In Reply To
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.


(This post was edited by usadomains on Aug 15, 2011, 7:04 PM)