Welcome

Cybermick Web and IT Services! Providing Cyber Solutions since 1998!
Mick Dobra Peoria, IL 309-340-2256
Specializing in Ubuntu Linux open source solutions, making high end IT solutions affordable for small businesses!

Sunday, December 29, 2013

Drupal Forms API

Doing some forms development in Drupal. I'm compiling some notes here.

If this is a topic of interest check back once in a while, I'll be adding notes and updates as a go through this particular project.

Development Goals: capture some data from A, pass to B for approval, pass approval to A and C or rejection to A. Confirm the workflow history.

Drupal modules use associative arrays and the form engine generates the HTML. Forms are processed in three phases: validation, submission, and redirection.

Function:

drupal_get_form()

Variables:

$form_id : a string to identify the form

$form : structured array describing the form

$form_state : information about the form, values
$form_state['redirect'] to a Drupal path to redirect the user. The last function to set this property wins. If not set the user is returned to the form.
See #redirect property below...

$_POST['form_id'] : present if form being processed has been submitted with data

Properties:

#submit : can contain an array of functions to process on submit

#redirect : set in $form_state['redirect'] or $form['#redirect']
example: $form['#redirect'] = 'node/1'

Requirements (particularly for your own form module):

.info : found in sites/all/modules/custom/[formname]/[formname.info]

.module : found in sites/all/modules/custom/[formname]/[formname.module]

References:

VanDyk, John K. "Pro Drupal Development, Second Edition"
http://www.apress.com/9781430209898

Sample email code: http://drupal.org/node/197122

VI editor commands: http://www.cs.rit.edu/~cslab/vi.html