Posted by python1340 on May 23, 2012 at 4:28pm
From what I understand, the proper place to put code to alter a form is in hook_form_alter. So I created a function mytheme_alpha_form_alter() and put it in template.php. Everything works fine, however the comments in template.php suggest that I should keep that file "as clean as possible" and to use the preprocess and process subfolders instead. So in trying to do things the proper alpha/omega way, I created a file preprocess/preprocess-page.inc and did the form modification code inside mytheme_alpha_preprocess_page(). This also works, but sure seems ugly. Is there a better way to modify a form without polluting the template.php file?
Comments
theme layer vs. module layer
If you are are changing forms template.php, there is a good chance that you may want it for other themes or projects. Why don't you create a custom module and place the preprocess functions in the .module file instead. You give up a layer of priority but it keeps your sub-theme cleaner.