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 nmsinc - December 9, 2013

Hi Dave,

Thanks for the suggestion, however, I have need of both .val and .text within the plugin, any suggestion?

nmsinc

nmsinc