Преглед изворни кода

Fixed a bug for ordering panels

Chun-Huai Cheng пре 9 година
родитељ
комит
5f83496dc1

+ 1 - 1
tripal_fields_layout/theme/templates/tripal_fields_layout_generic.tpl.php

@@ -99,7 +99,7 @@ foreach ($panels AS $panel_id => $panel) {
   
   $output = $horz_table . $vert_table . $ungrouped ;
 
-  // If this is a base content, do not organized the content in a fieldset
+  // If this is a base content, do not organize the content in a fieldset
   if ($panel->name == 'te_base') {
     $content .= $output;
   } else {

+ 8 - 6
tripal_fields_layout/tripal_fields_layout.module

@@ -589,12 +589,14 @@ function tripal_fields_layout_action_remove_panel (&$form_state) {
 function tripal_fields_layout_action_order_panels (&$form, &$form_state) {
   $panels = $form_state['values']['panel_items'];
   foreach ($panels AS $id => $panel) {
-    db_query('UPDATE {tripal_panels} SET weight = :weight WHERE panel_id = :id',
-      array(
-        ':weight' => $panel['weight'],
-        ':id' => $id
-      )
-    );
+    if (key_exists('weight', $panel)) {
+      db_query('UPDATE {tripal_panels} SET weight = :weight WHERE panel_id = :id',
+        array(
+          ':weight' => $panel['weight'],
+          ':id' => $id
+        )
+      );
+    }
   }
 }