Browse Source

Fixed the manage fields customizations (e.g. don't allow changes to cardinality)

Stephen Ficklin 9 years ago
parent
commit
f52507a792

+ 1 - 1
tripal_entities/includes/tripal_entities.fields.inc

@@ -267,7 +267,7 @@ function tripal_entities_field_is_empty($item, $field) {
  */
 function tripal_entities_organism_select_widget_validate($element, &$form_state) {
   $field_name = $element['#field_name'];
-
+dpm($form_state);
   // If the form ID is field_ui_field_edit_form, then the user is editing the
   // field's values in the manage fields form of Drupal.  We don't want
   // to validate it as if it were being used in a data entry form.

+ 6 - 2
tripal_entities/tripal_entities.module

@@ -367,9 +367,13 @@ function tripal_entity_load($id, $reset = FALSE) {
 function tripal_entities_form_alter(&$form, &$form_state, $form_id) {
   switch ($form_id) {
     case 'field_ui_field_edit_form':
+      // For entity fields added by Tripal Entities we don't want the
+      // the end-user to change the cardinality and the required fields
+      // such that record can't be saved in Chado.
+      // TODO: don't hard-code the 'SO' entity type.
       if ($form['#instance']['entity_type'] == 'SO') {
-        $form['field']['cardinality']['#default_value'] = 1;
-        $form['field']['#access'] = FALSE;
+         $form['field']['cardinality']['#access'] = FALSE;
+         $form['instance']['required']['#access'] = FALSE;
       }
       break;
   }