Display instructions for each option on a form

From semantic-mediawiki.org
Jump to: navigation, search

Semantic extension(s): Semantic Forms

Further extension(s): -/-

Keyword(s): -/-

Description:

Sometimes you have a list of options which should have instructions displayed next to each option. For example you're displaying a dropdown with a list of choices on a form, and you'd like to give a description for each item.

Label: Number of wheels on the vehicle

  • Option: 2 wheels (bikes or motorcycles)
  • Option: 3 wheels (rare)
  • Option: 4 wheels (cars)
  • Option: more than 4 wheels (trucks)

Here, you're providing instructions to the user to help them with which option to pick. But, you probably don't want to store that info in the page itself. So let's say your property page would ideally look like this:

  • [[allows value::2]]
  • [[allows value::3]]
  • [[allows value::4]]
  • [[allows value::more]]

In this way, the page only stores the minimal amount of data while the user is provided with precise instructions.

The solution is to modify MediaWiki:Common.js and add something like this:

jQuery(function() {
jQuery('option[value="2"]').html("2 wheels (bikes or motorcycles)");
jQuery('option[value="3"]').html("3 wheels (rare)");
jQuery('option[value="4"]').html("4 wheels (cars)");
jQuery('option[value="more"]').html("more than 4 wheels (trucks)");
});
  • Remember to refresh your cache!
  • Code provided by Yaron Koren