PDO Exception with Empty (Sub) Fields - Incorrect Decimal Format

Created on 1 December 2014, over 9 years ago
Updated 24 May 2024, about 1 month ago

I am not able to submit blank values for any MVF fields (that are optional). Even with the default value empty, and the default unit set to "-None-", if I do not enter a value for any MVF optional field, I get this error:

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect decimal value: '' for column 'field_annual_production_value' at row 1: INSERT INTO {field_data_field_annual_production} (entity_type, entity_id, revision_id, bundle, delta, language, field_annual_production_value, field_annual_production_target_id) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 3676 [:db_insert_placeholder_2] => 3788 [:db_insert_placeholder_3] => project [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => _none ) in field_sql_storage_field_storage_write() (line 494 of /home/nexampweb/dev/modules/field/modules/field_sql_storage/field_sql_storage.module).

I read here (http://drupal.stackexchange.com/questions/16051/pdoexception-incorrect-d...) that is has to do with a decimal type field attempting to be saved as NULL or a blank string ''. I also found there is some kind of logic that tries to account for empty values in this modules code, but it doesn't seem to attack the NULL issue:

(mvf.module:976)

/**
 * Implements hook_field_is_empty().
 */
function mvf_field_is_empty($item, $field) {
  // The logic is the following. Normally if at least one sub field is empty,
  // the entire field is considered empty. However, if it is value for default
  // value of MVF, we consider it empty only if all the sub fields are empty.

The solution on that linked article does not seem to help with this instance, however. Is there any way to fix this or workaround it without requiring the user to enter a value?

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States amaisano Boston

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024