When adding a new option to an attribute I get an error if I leave the cost field empty (as in, I delete the default 0.00) and then click save. The following error below prints out:

Notice: Uninitialized string offset: 0 in uc_attribute_option_form_validate() (line 462 of /home/user/public_html/sites/all/modules/ubercart/uc_attribute/uc_attribute.admin.inc).
Notice: Uninitialized string offset: 0 in uc_attribute_option_form_validate() (line 462 of /home/user/public_html/sites/all/modules/ubercart/uc_attribute/uc_attribute.admin.inc).
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect decimal value: '' for column 'cost' at row 1: INSERT INTO {uc_attribute_options} (aid, name, cost, price, weight, ordering) 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); Array ( [:db_insert_placeholder_0] => 2 [:db_insert_placeholder_1] => test option [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => 0.00 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 0 ) in drupal_write_record() (line 6861 of /home/user/public_html/includes/common.inc).

Comments

jeremyr’s picture

Of course the obvious solution would be to leave the 0.00 in the field, but that would be too easy... ;)

longwave’s picture

The latest patches in #1243762: Make field validation more consistent include a fix for this, testing would be appreciated.

longwave’s picture

Status: Active » Fixed

The patch in the above issue has been committed, so this is now fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.