Drupal: Custom Form Creation, Best Method

18,382

Solution 1

In drupal there is a Form API to do this, a very good working example is used in the documentation at drupal community, here are the links for that:

And one more thing Never go for hard coding things try taking the advantage of all available API's.

Solution 2

Drupal.org contains detailed tutorials on how to create modules, see for example this one.

The Drupal Form API will be your friend to handle easy data capture: How to use the Form API.

Depending on your data capture needs, the Webform module may already do what you want.

Solution 3

You haven't detailed who the users are that will be inputting data into the form, the complexity of the form or what you will do with the data so I'd like to present you with some other options.

Custom Content Type

You can create a custom Content Type and assign appropriate permissions so that users can fill in the content creation form and it can be saved in the database as a Node entity. The Node is a core Drupal entity and therefore already has many built in capabilities for sorting and displaying using the Views module and permissioning, etc.

But the users filling in the "forms" (ie. creating Nodes) have to be registered Drupal users.

Webforms Module

Drupal has a Webforms module which will allow you to create a form without having to do any custom coding. The module looks after creating database tables and already has a lot of built-in functionality.

Refer to the other answers if you find that it's still most appropriate to create your own module.

Share:
18,382
LoneWolfPR
Author by

LoneWolfPR

I'm a professional developer. On a day to day basis I use HTML, JavaScript, JQuery, CSS, XML, PHP and MySQL. On a less regular basis I develop for Android and iOS.

Updated on June 04, 2022

Comments

  • LoneWolfPR
    LoneWolfPR almost 2 years

    I'm relatively new to Drupal, but not CMS's in general. I'm creating a site for a client. The most important part is creating a fairly complex form in which users input various types of data to be stored in the database. I had assumed the best method for doing this was to create a custom module. Is this the case, and if so can someone direct me to documentation or a tutorial on the best way to create a module of this nature? If not, I'm open to suggestion for the best way to create this kind of form even if it is hardcoding the content.

  • bandolero
    bandolero over 10 years
    Webform module can solve a pretty wide range of tasks!
  • nerdoc
    nerdoc about 9 years
    "How to use Form API in Drupal 7" is a dead link.