Join Jon Peck for an in-depth discussion in this video Validating user input for a content type, part of Drupal 7: Custom Module Development.
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 caches. …Once cleared, the hook_form_altar debugging information will be shown for every form. …
- Creating your first module
- Interacting with hooks
- Working with permissions and roles
- Controlling access
- Adding a menu item to an admin interface
- Using the Form API (FAPI) to quickly create a form
- Creating custom form validation
- Manually creating a custom content type
- Validating user input
- Importing content using feeds
- Creating a block
- Understanding best practices and coding standards
Skill Level Advanced
Q: gmap3_tools is not working the way I expected it to. What version of gmap3_tools should I be using?
A: Use the free exercise file containing the version of gmap3_tools used for recording; the published version of the module on drupal.org has changed since recording and is not backwards compatible.
Q: I attempted to run the Drupal site root from the project files, but the site isn't loading. Why not?
A: The Drupal configuration file in sites/default/settings.php contains database configuration specific to the environment used to record the movie. This may be different than your environment. Edit the file and search for "windfarms" - you may need to change the database host, username, password, db name and port to match your specific environment.