Hi there,

I am pretty new to Drupal module development. I read some examples. It seems that it's best to use a module for a form. For example, if I have a "Contact us" form, I'd like develop a contact_us module and have the form defined in the module; similarly, if I have a "Feedback" form, I'd like go with a feedback form.

In the same time, in the module, I do some coding on the hook_menu to give this module a path, say, contact, feedback.

Is my understanding right?

Thanks

Comments

nevets’s picture

Pretty much though on one module can have any number of forms. I think a better way to look at a module is that it provides some function, in the case of your question one module provides "contact us" functionality, the other "feedback" functionality. Note there are contact module already available as part of Drupal 5 (including one that comes with core) and the webform module can be used to provide both a contact us form and a feedback form without any coding.

avpaderno’s picture

Modules can have any forms they need to reach their purpose; the number of forms depends from the complexity of the module itself.

-- Kiam@AVPnet

yelvington’s picture

Writing no module at all is the best option, given the existence of the very fine Webform module.

dksdev01’s picture

Webform is best if you just need form and simple validation.

-Deepak

modul’s picture

Maybe I haven't been sufficiently drupalized yet, but somehow I always feel a bit weary when I need to write a module. With regard to forms, I have collected them in a functions.php file, which contains all my useful php goodies, but also the input, validation and submit function for each form, so 3 php functions per form. It works fine, and it allows me to keep everything in one file (which, admittedly, is becoming slightly big :-). Anyway, just to say that you don't need to write a module, but that you can also include the form functionality in any readily available php file. In the end, it's all php, module or not.