hi,

I need a modification in the forum module. I need to add one more field to be entered while creating a forum topic.Other than the Subject, Forums(Select), and the body of the forum. The field will be for the contact number of the user who is submitting the forum. I had created the field by adding to the forum_form hook of the forum module the following code fragment.

$form['phone'] = array('#type' => 'textfield', '#title' => t('Contact No'), '#default_value' => $phone, '#required' => TRUE, '#weight' => 3);

It gives me the required results. Now I would need to make the textfield accept only numbers and not characters. I have a javascript function. But how to implement it in drupal?

Also I would need to set the size of the textfield also. Can I use something like #size in drupal. I dont see any effect upon giving like this.(I added a #size parameter at the end)

$form['phone'] = array('#type' => 'textfield', '#title' => t('Contact No'), '#default_value' => $phone, '#required' => TRUE, '#weight' => 3, '#size'=>'10');

Can any one tell me where these #type, #title, #default_value, #required, #weight are defined. Do I need to define this #size anywhere prior to using it.

thanks in advance
drupal_india

Comments

Frando’s picture

drupal_india’s picture

Thanks Frando for your reference. But even after giving the #size parameter for the textfield I have the usual size in the form.

Can any one help in the other problem -> I want a user to only enter numbers to be entered in a field nothing else(no alphabets). How to make use of form validate for that??
thanks
drupal_india