浏览代码

Some small fixes

Stephen Ficklin 9 年之前
父节点
当前提交
442a0d3d24

+ 6 - 5
tripal_entities/includes/tripal_entities.admin.inc

@@ -411,7 +411,7 @@ function tripal_entities_add_bundle_fields($entity_type_name, $bundle_name, $cvt
 
       // Determine if the field is required.
       $is_required = 0;
-      if (array_key_exists('not null', $details)) {
+      if (array_key_exists('not null', $details) and $details['not null'] === TRUE) {
         $is_required = $details['not null'] ? 1 : 0;
       }
 
@@ -464,9 +464,13 @@ function tripal_entities_add_bundle_fields($entity_type_name, $bundle_name, $cvt
         case 'boolean':
           $field_type = 'list_boolean';
           $widget_type = 'options_onoff';
+          $settings['allowed_values'] = array(0 => "No", 1 => "Yes");
+          // Turn off the is_required, even if it is because a non-checked
+          // field is a value.
           $is_required = 0;
           break;
         case 'datetime':
+          //$field_type = 'datestamp';
           // TODO: What is the proper datetime fields ??????
           break;
         default:
@@ -529,11 +533,8 @@ function tripal_entities_add_bundle_fields($entity_type_name, $bundle_name, $cvt
           'storage' => array(
             'type' => 'field_chado_storage'
           ),
+          'settings' => $settings,
         );
-        //add the default values for the boolean field
-        if ($field_type == 'list_boolean') {
-          $field['settings'] = array('allowed_values' => array(0 => 0, 1 => 1),);
-        }
         field_create_field($field);
       }
 

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

@@ -117,7 +117,7 @@ function tripal_entities_field_storage_write_recursive($entity_type, $entity,
   // are for this table.  Then add their values to the $values array.
   foreach ($field_vals as $field_name => $field_val) {
     // If the field value is empty then continue.
-    if (!$field_val) {
+    if (!isset($field_val) or $field_val === '' or $field_val === NULL) {
       continue;
     }
     if (preg_match('/^' . $tablename . '__(.*)/', $field_name, $matches)) {

+ 1 - 0
tripal_entities/tripal_entities.info

@@ -13,4 +13,5 @@ dependencies[] = tripal_views
 dependencies[] = tripal_db
 dependencies[] = tripal_cv
 
+dependencies[] = date_api
 dependencies[] = entity