Browse Source

Add support for #weight to TripalImporter form.

Lacey Sanderson 6 years ago
parent
commit
340654dee0
1 changed files with 10 additions and 1 deletions
  1. 10 1
      tripal/includes/tripal.importer.inc

+ 10 - 1
tripal/includes/tripal.importer.inc

@@ -94,9 +94,18 @@ function tripal_get_importer_form($form, &$form_state, $class) {
     );
   }
 
+  // Retrieve the forms from the custom TripalImporter class
+  // for this loader.
   $importer = new $class();
   $element = array();
-  $form['class_elements'] = $importer->form($element, $form_state);
+  $element_form = $importer->form($element, $form_state);
+  // Quick check to make sure we had an array returned so array_merge() works.
+  if (!is_array($element_form)) $element_form = arry();
+ 
+  // Merge the custom form with our default one.
+  // This way, the custom TripalImporter can use the #weight property
+  // to change the order of their elements in reference to the default ones.
+  $form = array_merge($form, $element_form);
 
   $form['button'] = array(
     '#type' => 'submit',