Hide a link field with javascript rule

georgie

Member
Hi !

I would hide a field using the link plugin if it is empty, but it does not work, how to make please ?

Thank you !
 
Sorry, but I re-open this thread.

Have you a solution to hide a field using the link plugin ?

Indeed Javascript rules, conventionally used, do not run with the plugin.

Thank you !
 
I think that's probably because the link element is never truly "empty", if I recall correctly it always has a JSON string representing the two parts of the element.

Checking on it now.

-- hugh
 
Yeah, it's problematic. You won't be able to use the canned event setups, you'll have to do this in the custom JS box instead. Leave the 'Event' as 'load', unset all the other menu selection, and put something like this in the custom JS box

Code:
if (JSON.encode(Fabrik.getBlock('form_17').formElements.get('fab_bands_test___video_link').getValue()) == '["","http://"]') {
  Fabrik.getBlock('form_17').formElements.get('fab_bands_test___userid').hide();
}

Change the 17's to your numeric form ID, and the two full element names to match your names.

You'll probably also want a 'change' event something like this:

Code:
if (JSON.encode(Fabrik.getBlock('form_17').formElements.get('fab_bands_test___video_link').getValue()) == '["","http://"]') {
  Fabrik.getBlock('form_17').formElements.get('fab_bands_test___userid').hide();
}
else {
  Fabrik.getBlock('form_17').formElements.get('fab_bands_test___userid').show();
}

... although you may want to tweak that code a little, and test for both parts being empty strings, like ["",""], in case you delete the default "http://".

http://screencast.com/t/HxF1RgcTw6

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top