This module allows to pass form element default values into URLs and substitute them into form elements. This is very useful when you have a content type with fields and you want to build a link which must open a node adding form with several fields already initialized with default values.

We support the following form elements:

  • Standard FAPI
    1. text
    2. textarea
    3. checkbox
    4. select ( + multiple)
  • CCK Fields:
    1. text ( + multiple)
    2. number ( + multiple)
    3. date ( + multiple)
    4. user reference ( + multiple)
    5. node reference ( + multiple)
    6. NEW email ( + multiple)
    7. NEW taxonomy ( + multiple)
  • Webform elements
    1. date
    2. email
    3. hidden
    4. markup
    5. select (+ multiple)
    6. textarea
    7. textfield

Usage:

To pass a field default value use this field1=value1 or field1=value1||value2 for a field in a multiple mode. Use ^0 marker to hide this field from the form (you may want to initialize a field and disable an ability to change it). Also you can use ^1 marker to convert this field into markup (title and value are visible) or ^2 marker to convert this field into disabled (eq disabled="disabled" in HTML code) form element*.
NOTE: webform date and all cck fields does not support ^2 marker!

Use cases:

Case 1

You have two content types Group and Item. Item has a Node Reference to the Group. You want to put a link on the Group page 'Add an item to this group'. This link will open a node add form for the new Item and you want a Group node reference field to be initialized with the NID of the Group you are comming from. Use syntax like this:
http://site.com?field_group=125 to set the default value which can be changed by the user or
http://site.com?field_group=125^0 to initialize the field and hide it from the form so that user can't change it. So you can guarantee that the saved Item will refer the needed Group.

Case 2

You have a 'Request More Information About a Product' webform with a Product ID text field. You have a list of products each of which has a link pointing to this webform. You want to pass product ID so it is populated into webform Product ID field and is sent to the contact person. Use this syntax:
http://site.com?product_id=658375^0 or
http://site.com?product_id=658375^2 if you want to show field to your visitors, but don't want it to be changed by user. Also you can try ^1 marker to convert field to markup.

Case 3

You have an Item content type with multiple Names (textfield) and multiple Recepients (email/text). You want to provide a link which will populated 3 names and emails to the Item node add form. Use this syntax:
http://site.com?field_name=Marc||Tommy||Jessica&field_email=a@gmail.com||b@gmail.com

New in version 6.x-1.4

Added programmable access to field default values through elementdefaults_alter hook. That means if you want to set up default values of specific field you can do this by adding yourmodule_elementdefaults_alter implementation in your module or theme with this code:

<?php
function mymodule_elementdefaults_alter($request) {
 
$request['my_cck_field']='value1||value2||value3^1';
  return
$request;
}
?>

NOTE: $form[#elementdefaults]['element_name']='value' is no more support in version 6.x-1.4

We have a co-maintainer of this module - ershov.andrey.

Project Information

Downloads