Browse Source

Fixed a major bug with web service field alter but minor code change

Stephen Ficklin 6 years ago
parent
commit
47400cb0e7
2 changed files with 6 additions and 2 deletions
  1. 1 1
      tripal_chado/tripal_chado.module
  2. 5 1
      tripal_ws/tripal_ws.module

+ 1 - 1
tripal_chado/tripal_chado.module

@@ -1054,7 +1054,7 @@ function tripal_chado_form_field_ui_field_edit_form_alter(&$form, &$form_state,
 
     // If this is a Chado field we need to preserve the Chado elements of the
     // settings or they will be lost if a user edits the field settings.
-    if (array_key_Exists('chado_table', $form['#instance']['settings'])) {
+    if (array_key_exists('chado_table', $form['#instance']['settings'])) {
       $form['instance']['settings']['base_table'] = array(
         '#type' => 'value',
         '#value' => $form['#instance']['settings']['base_table'],

+ 5 - 1
tripal_ws/tripal_ws.module

@@ -438,8 +438,12 @@ function tripal_ws_load_remote_entity($site_id, $api_version, $ctype, $id) {
 }
 
 function tripal_ws_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
+  // Don't let the user change the cardinality of web services fields
   if ($form['#instance']['entity_type'] == 'TripalEntity') {
+    if ($form['#field']['storage']['type'] == 'field_tripal_ws_storage') {
       $form['field']['cardinality']['#access'] = FALSE;
+      $form['instance']['required']['#access'] = FALSE;
+    }
   }
 }
 
@@ -472,4 +476,4 @@ function tripal_ws_entity_info_alter(&$entity_info) {
       'custom settings' => FALSE,
     ),
   );
-}
+}