Tej
Tej

Reputation: 11

Forms in Drupal

I am using built in fields for creating form in Drupal. Can anybody help me about how and where to code that will be executed on submission of form?

Thanks in advance.

Upvotes: 0

Views: 61

Answers (2)

Sumoanand
Sumoanand

Reputation: 8929

The way it works is suppose your form name is "XYZ", your form elements will be declared under XYZ_form function:

function XYZ_form($form_state){
....
}

Code for validation will go under XYZ_form_validate function:

function XYZ_form_validate($form, &$form_state){
..
}

And code to execute on form submit will go under XYZ_form_submit function:

function XYZ_form_submit($form, &$form_state){
...
}

More details can be found here: https://drupal.org/node/37775

Upvotes: 2

rix
rix

Reputation: 10632

If you want a custom form you can make a module, and have the module provide the form.

You use hooks in the module to control parts of the form such as validation, submission and data processing. You'll use the form API to help you write the code to provide the form elements.

If you want a form without coding you can use the webforms module.

Upvotes: 0

Related Questions