瀏覽代碼

Add support for #weight to TripalImporter form.

Lacey Sanderson 6 年之前
父節點
當前提交
340654dee0
共有 1 個文件被更改,包括 10 次插入1 次删除
  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',