Show Hide Fields

By nmsinc - December 3, 2013

I'm saving a section that stores 'num, title, company.

The field grabs data from another section by 'num' and not by 'title'; however, I need to filter the show/hide by 'title' - how can this be done? I have listed the current show/hide section below!

// 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']['claims_submission']['claim_status'] = array(
  // list option       => fields to show
  ''                        => array(), // show these fields when the topmost '<select>' option is selected
  'Other'               => array('status_other'), 
  '_any_value_'   => array(),  // show these fields when a value not listed above is selected
);

Thanks - nmsinc

nmsinc

By Dave - December 8, 2013

Hi nmsinc, 

Unfortunately it doesn't do that, and you should be try and avoid using labels instead of values because if a user changes the "title" in the other section it will break your code.  There may be a way to update the structure of your CMS to use nums throughout.

That said, try this patch if you want to update the plugin to match on option text instead of option value:

Replace:

var value = $('SELECT[name="' + listFieldName + '"] OPTION:selected').val();

With:

var value = $('SELECT[name="' + listFieldName + '"] OPTION:selected').text();

Also, anytime I update a plugin with custom modifications I like to rename it showHideDependantFields_CUSTOM.php or something like that, so I don't forget and accidentally overwrite my custom code when upgrading the plugin in future.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By Dave - December 12, 2013

Hi nmsinc,

Hmm.  Not really.  Maybe, you could copy the entire javascript for() { } block and change the .val to .text in that block, so it would be doing one for() block after another.  But you'll need to do some testing at that point to be sure it's all working as expected.  So either customize that plugin as needed, or creating custom code would be the path forward.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com