소스 검색

Merge pull request #900 from tripal/852-tv3-publish

Add more error checking to the publish form.
Stephen Ficklin 6 년 전
부모
커밋
8e029f7829
1개의 변경된 파일13개의 추가작업 그리고 1개의 파일을 삭제
  1. 13 1
      tripal_chado/includes/tripal_chado.publish.inc

+ 13 - 1
tripal_chado/includes/tripal_chado.publish.inc

@@ -90,10 +90,22 @@ function tripal_chado_publish_form($form, &$form_state) {
 
         // Now call the widget callback function to let the module adjust the
         // element as needed.
+        if (!isset($instance['widget']['module'])) {
+          tripal_report_error(
+            'tripal_chado',
+            TRIPAL_ERROR,
+            "No module set for field :name widget.",
+            [':name' => $instance['field_name']]
+          );
+          $instance['widget']['module'] = 'tripal';
+        }
         $function = $instance['widget']['module'] . '_field_widget_form';
         $items = [];
         $delta = 0;
-        $element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
+        $element = [];
+        if (function_exists($function)) {
+          $element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
+        }
 
         // None of these fields are required, so turn off that setting.
         $element['#required'] = FALSE;