On Fri, 04 May 2007 11:15:12 -0700, Earl Miles <merlin@logrus.com> wrote:
Larry Garfield wrote:
1) Forms that are used as a page handler, if factored out to separate files, may never be called from drupal_execute(). I do not consider this acceptable.
This doesn't follow. If I put my form in foo.pages.inc and use drupal_get_form as the callback, and provide my include so that my foo.pages.inc is loaded when that menu is hit, my form will be there. This, of course, isn't true if this form is also available in a non-page-context, which can happen, but in that case the form should be embedded into the .module anyway.
drupal_execute() is a non-page context. Take for example node_type_form, the form function for which is node_form. It's a non-settings-page form that is used as a parameter to a callback on drupal_get_form, and is rarely used but reasonably large so it's a great candidate for factoring out of the main node.module file. If we factor it out into a pages include file for the node module, then it gets loaded when a user visits admin/content/types/page. Great. What happens, though, if someone calls drupal_execute('node_type_form', ...)? How does the system know where to find that form and how to load it if drupal_execute() doesn't have some knowledge of where forms live? Either drupal_get_form() and drupal_execute() have to be able to dynamically load the form or that form now becomes inaccessible except through the page handler. If you have a suggestion for how to factor page forms out into separate files but not have a form-loading system without breaking drupal_execute() please share it, because I can't think of one.
I want to emphasize that "where appropriate". Not all handlers or forms should be split out into separate files. For instance, I'd argue the most often used page handler is node_view(), and the most often used forms are the login block and search block. We should *not* split those out into separate files. They're used often enough that their extra weight on other page loads
You actually mean node_page(), not node_view() =)
Yes. Yes I do. :-) --Larry Garfield