Hi,

I'm working on converting a module for www.projectopus.com to 4.7. This module, I call it the "Gardener Module", helps admin's merge, group, migrate, and do other mass operations on Taxonomy terms.

Info:

  • The rendered form is in the form of a table, where some of the columns are form fields.
  • This table is a list of ALL the taxonomy terms in the system (don't ask why please..) so it is large. Large enough that memory management is an important consideration
  • I am currently building this form by looping through all the terms and building each row, adding form elements where necessary with form_checkbox .. etc.

The Problem(s):

  • Drupal 4.7 seems to want forms to be created in a more orderly way. From what I've done so far the accepted practise is
    function my_form() {
      //make a form, aka really long loop #1
      foreach ($huge_number_of_terms as $term) {
        // Store a crazy big $form array in memory....
      }
      return $form; // Return the huge form.
    }
    
    function theme_my_form(&$form) {
      // Loop through each term since I need more information from each term, aka really long loop #2
      foreach ($huge_number_of_terms as $term) {
        $rows[] = //make a really really long table with the huge form array.
      }
    }
    

So, basically, in 4.6 I could write this all in one function (saving myself having to build the form array) but 4.7 want's me to double my code execution time and nearly double my memory footprint (since I have to loop through all my terms 2x).

Am I missing something? Is there an easier way to do this?

Please let me know if you want more details, or my logic is confusing.

Thanks!

James Andres
Lead Developer - www.projectopus.com