How to Save Variables and Handle Form Submissions


show more Handling successful form submissions and saving variables provides you with in-depth training on Developer. Taught by Jon Peck as part of the Drupal 7 Custom Module Development show less
please wait ...

Handling successful form submissions and saving variables

Once validation is passed, the Drupal form API looks for submit callback. Return to the IDE, then create a new docblock for the submission callback. Process a validated Wind Farm admin setting submission. Similar to the way the validate function was named, a submit callback name starts with the form name followed by underscore submit. Same as a validate function, it takes two parameters; the form then the form state passed by reference; windfarms_admin_settings_form_submit, form then form_state, passed by reference.

The first thing I want to do is tell the form to rebuild so the submitted values will be displayed even on success, instead of showing the default values. To do that I will manually set a flag in the form state. As form state was passed by reference, changes within this function will affect other form processors. The flag name is rebuild and accept Boolean values true or false. I'll start with a comment to describe what I'm about to do; Rebuild the form, ...

Handling successful form submissions and saving variables
Video duration: 6m 45s 2h 56m Advanced

Viewers:

Handling successful form submissions and saving variables provides you with in-depth training on Developer. Taught by Jon Peck as part of the Drupal 7 Custom Module Development

Subjects:
Developer Web
Software:
Drupal
Author:
please wait ...