Creating a configuration settings form for your module

Drupal: 24m
Video Series
Information

This video goes through the process of creating a configuration form in order to save settings to the variables table in the database, and how to integrate those variables into your module.

Discussion

Comments on this video

Comments here have been temporarily disabled. Please drop a line with our support for any questions or comments about the videos, blog posts, or about the site generally.

Great video! I hit a snag early on that doesn't make sense to me. I'm at the 12 minute 45 second mark in the video and when I click save for the configuration page I created for my own module the items get into the database but they are not saved in the form. Enabling the attached demo module works fine. Your values are saved for your demo module but mine are not and I cannot see any differences in how my code is written. I'm baffled.

In this video you mention that we could do validation upon the submitting the module configuration form, but you don't mention how that would be done. I presume that we can also do stuff upon submitting the module configuration form as well, but that isn't discussed either.

I'm currently trying to figure out how I can programmatically create a new views page upon submitting the form for my own module configuration.

What I think I need to do is call hook_views_default_views_alter after submitting the module configuration form, but I can't find a way to do that. I'm assuming there must be some special function like the one used in this video when you returned the the configuration form.

Thanks in advance for any assistance you can give me to point me in the right direction. I've been searching for an answer to this all day.

Steve

The simple thing to do would be to just create a form via the normal means and not use the system_settings_form() helper. Check out this video for some ideas.

http://drupalize.me/videos/creating-submitting-and-validating-simple-form

Or, you could use the #submit and #validate Form API properties to call your custom functions in addition to whatever it is that system_settings_form() is doing.

http://api.drupal.org/api/drupal/developer%21topics%21forms_api_referenc...

Thanks for the quick reply, Joe. It validates exactly how I decided to proceed today and I'm working on it now. That certainly helps my confidence in what I'm doing!

All the best and thanks again to you and all the Lullabots for these great videos!

Steve

Lullabot logo

Lullabot has trained thousands of Drupal developers & guided the development of some of the largest Drupal websites.