Joomla Webform alternative: JForms

I don’t use Joomla, but sometimes a friend or a colleague of mine ask me some tips. My answer could be: in Drupal it will take 5 minutes.

Since I’m very open-minded, today instead of replying in that awkward way I try to found an alternative to a very useful module for Drupal called Webform. I’ve found a limited but working equivalent for Joomla called JForms.

Tested on:

Installation:

  1. Install the extension using URL installation and paste the extension link (zip file from link above).
  2. Create a new form (see the visual howto below) with at least one field, one button, a form title, and a Thank you page (eg. index.php)
  3. Save the form.
  4. Create a new menu item from Menu > Main Menu > JForms > Standard forms  and fill the Select Form field.

Now that you’ve a form, you can use it from your site (click on menu item written created on (4) ).

If you have to link two forms together (eg. Customers -> Company), you have to use the DBList field.

  1. Create the Firm form
  2. Create the Customers form
  3. On Customers form add a DBList field

DB List field must have these values:

Table name #__jforms_9c7aa
Field key id
Field value hcf94
Field sort hcf94
  • Table name is the table name (mydbprefix_jforms_9c7aa) with the placeholder #__ instead of mydbprefix_.
  • Field key is id. The form select value will be set to an univocal id instead of the raw value.
  • Field value: value as displayed by the user.
  • Field sort: sort the list by this field.

HTML result:

<select style="width: 70px;" id="h4443_14" name="h4443[]">
<option selected="selected" value="1">Barilla</option>
<option value="2">Parmalat</option>
</select>

When creating a new customer, you’ll see a dropdown with a list of companies from the Company table and the two forms are connected.

See also:

Image submit buttons on Drupal 5.10

I follow this useful howto by Tom Constant on how to add image submit buttons on Drupal forms. Since I got a JavaScript error on drupal.js (line 31: button is undefined), I rewrite Tom’s implementation, and now it works fine on Drupal 5.10:

function phptemplate_button($element) {
  // Make sure not to overwrite classes.
  if (isset($element['#attributes']['class'])) {
    $element['#attributes']['class'] = 'form-'. $element['#button_type'] .' '.
 $element['#attributes']['class'];
  }
  else {
    $element['#attributes']['class'] = 'form-'. $element['#button_type'];
  }

  // here the novelty begins: check if #button_type is normal submit
  // button or image button
  switch($element['#button_type']) {
	case 'image': $button_type = 'image';
	break;
	default: $button_type = 'submit';
	break;
  }
  return '<input id="'. $element['#id'].'" name="'. $element['#name'] .'"
 type="' . $button_type . '" value="'. check_plain($element['#value']) .'" />