tags:

views:

491

answers:

1

I'am trying to develop a Custom drupal module which will read arguments from the URL and populate the form fields accordingly.

I was successful in doing that for title filed but i was unable to that for body field and a custom cck field, i named field_url

here is my code

function formexample_form_alter(&$form, &$form_state, $form_id) {
// This code gets called for every form Drupal builds; use an if statement
// to respond only to the user login block and user login forms.
if ($form_id == 'bookmark_node_form') {
$form['title']['#value'] = $_GET['x'];
$form['field_url']['#value'] = $_GET['y'];
$form['body']['#default_value'] = $_GET['x'];
}
}

here is my url i am trying to enter http://localhost:8082/acquia-drupal/node/add/bookmark?x=hjsajskajsjasa&y=asasasasas

title field is getting populate with the value of x from the url arguments but other fields don't.

+1  A: 

You might look to the Prepopulate module for inspiration, if it doesn't achieve your needs on its own.

Grayside
thank u very much this is exactly what i am looking for.
pmarreddy

related questions