PHPJavascript

Web Development Guide – My Personal Library of Tutorials and Scripts

Drupal form_alter not working

June15

I was creating a custom module to add a default weight for product in ubercart. I was using the hook_form_alter got the reference from this page. But i realized that the module was not working.

The form_alter function will not work for drupal 6.

I had to use the following syntax:
function modulename_form_alter(&$form, $form_state, $form_id) {

Such that the example given on the page mentioned above for my_module.module will be as follows

<?php
// $Id$

/**
* @file
* Module to hold my customizations to Ubercart
*/

/**
* Implementation of hook_form_alter()
*/
function my_module_form_alter(&$form, $form_state, $form_id) {
if ($form_id == ‘product_node_form’) {
$form['base']['model']['#required'] = FALSE;
}
}

posted under Drupal, Ubercart

Email will not be published

Website example

Your Comment:

 

12,958 spam comments
blocked by
Akismet