Validate User Input for a Content Type to Control Access


show more Validating user input for a content type 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 ...

Validating user input for a content type

In the previous segment, each field instance had a widget associated with it. The widget provides a form API structure that is used when creating and editing a node of that content type. As the form API was used, I can leverage Drupal system of hooks that allows modules to interact with one another. Hook_form_alter alters a form before it's rendered. Return to the IDE and open windfarms.module, and navigate to the end, start with the DocBlock, Implements hook_form_alter(), then the function; like other hooks, start with the module name.

It takes three parameters: the form, passed by reference, the form_state also passed by reference, and a form_id. I want to add validation to the node edit form and I don't know the form_id, therefore I'm going to add some debugging information; dpm($form_id) and I'd like to see the structure of the form, so dpm($form), save, then return to the browser, then clear all caches.

Go to Configuration > Performance, then Clear all c...

Validating user input for a content type
Video duration: 13m 12s 2h 56m Advanced

Viewers:

Validating user input for a content type 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 ...