Subject speaks for itself, I think. Other data types (alphanumeric, etc.) show back up in the webform for an authenticated user, but my one "money" field is not being populated and shows up as either "select" (if I make it required) or "none" (if I make it optional). The data previously submitted is definitely in the CiviCRM record for the user.

Comments

colemanw’s picture

This doesn't seem to be a problem in the 2.x branch. Give it a try and let me know.

m.e.’s picture

Just installed rc4 but still not having any luck with money data. It is still updating in the CiviCRM record - just not populating back into the form, whether I make it required or optional. Other field types are still doing fine.

(Great new features in the 2.x branch, BTW!)

m.e.’s picture

Have also just encountered a similar error. A new CiviCRM custom data field has 4 checkboxes, no defaults, optional. The first checkbox is always turned on when I load the form and (unlike the above problem) the field is also marked selected in the CiviCRM record for that user. If I unselect the checkbox and submit, then go back to the form, it is once more checked.

This one checkbox is the first option I created for the field and, originally, it did default to checked. Later I removed this default. I've tried removing the field from the form and then re-selecting it, but no dice.

colemanw’s picture

In both cases, I need to know:
-what type of data is being stored? (I know the first is money)
-what civicrm form element is being used? (I know the second is checkbox, but what about the first?)

in the second example, is the data being saved in civicrm at all?

colemanw’s picture

Version: 7.x-1.4 » 7.x-2.x-dev

I have tried different variants of this on my test server and can't reproduce your problem.
Contact me with your server's login info and SSH access if you would like me to investigate further.

m.e.’s picture

The fields that are working fine are checkboxes, radio buttons, and select lists. Some of my fields are using the Webform option to display as a List (dropdown). The well-behaving fields are all alphanumeric.

The problematic money field is -

Money, Select (in CiviCRM)
Type Select but display as List (in Webform)
Mandatory
Not conditional
PROBLEM: Values changed on form make it into CiviCRM but are not prepopulated back into form for same user.

I want to do some more fiddling with the 2nd field before you spend time on it because the error I'm seeing may actually be related to a GUI issue. CiviCRM is allowing very long field labels which apparently Webform doesn't like, so it will not let me save the Web Components GUI. (I can shorten some of the labels there, but others it prevents for some reason.) This GUI currently has "mandatory" selected (not sure why) and because I can't save when I uncheck it it's possible this is causing one option to force itself on. (BTW I'm not sure if the label length issue is an incompatibility or bug or what -- in this case I can probably just re-label the checkboxes in CiviCRM, remove and re-add the field in the CiviCRM tab, and see if that does the trick.)

m.e.’s picture

OK, I've done more testing and have more information. Both problems do still exist but with changes from before.

1. Now, (required) money data entered on the Webform is not being recorded into the CiviCRM record for the user. Re-loading the form still shows -SELECT- in the dropdown, which I guess now makes more sense since CiviCRM doesn't know the value previously chosen.

2. I can now save the Web components GUI for the alphanumeric checkbox field that previously had too-long labels. It's been removed from the form and re-added from CiviCRM with its new shorter labels, as a non-mandatory field without a default. It's behaving inconsistently. At first it displayed properly, with nothing checked. I checked one option and submitted, and it did store this in the record. Then I unchecked and saved again, but it is still showing as selected in the CiviCRM. It's as if - once selected - this field doesn't want to unselect. I should point out that I added this field very recently, after my CiviCRM upgrade (but before upgrading Webform_CiviCRM to 2.x). Fields that are behaving well were all created quite a while ago. I have no idea if this matters, but thought I'd mention it.

colemanw’s picture

I'll take one more look into the money situation.
For the second issue, I recently fixed a bug where checkboxes wouldn't record in CiviCRM if nothing was selected. Try using the latest -dev.

m.e.’s picture

I just tried to edit one of my money values in the Custom Data GUI and got a weird error. I'm starting to wonder if old API bugs may have gotten my data values off to a bad start, rather than a specific module problem? I've pasted the backtrace below.

Error: Sorry. A non-recoverable error has occurred.
One of parameters (value: 1,000.00) is not of the type Money (note: this is the format that is populated when I open the field - I tried removing the comma and got the same error)

/sites/all/modules/civicrm/CRM/Core/Error.php, backtrace, 296
/sites/all/modules/civicrm/CRM/Utils/Type.php, fatal, 268
/sites/all/modules/civicrm/CRM/Core/DAO.php, validate, 928
/sites/all/modules/civicrm/CRM/Core/DAO.php, composeQuery, 865
/sites/all/modules/civicrm/CRM/Core/BAO/CustomOption.php, executeQuery, 276
/sites/all/modules/civicrm/CRM/Custom/Form/Option.php, updateCustomValues, 396
/sites/all/modules/civicrm/CRM/Core/Form.php, postProcess, 250
/sites/all/modules/civicrm/CRM/Core/StateMachine.php, mainProcess, 167
/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Next.php, perform, 64
/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php, perform, 203
/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php, handle, 103
/sites/all/modules/civicrm/CRM/Core/Controller.php, handle, 284
/sites/all/modules/civicrm/CRM/Custom/Page/Option.php, run, 247
/sites/all/modules/civicrm/CRM/Custom/Page/Option.php, edit, 304
/sites/all/modules/civicrm/CRM/Core/Invoke.php, run, 224
/sites/all/modules/civicrm/drupal/civicrm.module, invoke, 443
, civicrm_invoke,
/includes/menu.inc, call_user_func_array, 503
/index.php, menu_execute_active_handler, 21

m.e.’s picture

Newly discovered, related problem: Brand new Webform containing brand new CiviCRM money fields + alphnumeric checkbox/list fields is not saving any of the form data into the CiviCRM record at all. It does create an Activity record, however. As a test, I also created a 2-field form with some brand new checkbox and select list (but no money) fields, and it did save the data into the contact's record.

Upgrading to the latest .dev version as of 8/27, and to Webform 3.12, did not solve this problem.

Status of money field issue has not changed, either. Money data is being saved into CiviCRM but is not being prepopulated back into the form for an authenticated user. Other fields are still fine (checkboxes, select lists, a date, etc.).

colemanw’s picture

Since I haven't been able to reproduce any of this on my test server, can I log in to yours? PM me on IRC with url, drupal login, and preferably SSH login.

colemanw’s picture

I think I've found your answer:
CiviCRM always formats money values in the database like so: 50,000.00 (although it sometimes leaves off the trailing zeroes).
But the value that it actually wants to read and write is 50000.00 (no comma, always trailing zeroes).
I have patched webform_civicrm to always run money values through number_format() and strip commas before populating webform options.
So, download the latest -dev, visit the "edit webform component" page of all your money fields to refresh their options (you'll need to re-select the checkboxes and reset defaults), and all your money problems should be over :)

colemanw’s picture

There are still issues with this in CiviCRM core (which occur while editing a contact via Civi as well as Webform). See http://issues.civicrm.org/jira/browse/CRM-8786

The big problems occur when "0" is a valid option, and when the form element is not mandatory and the user can choose to "select none." You may wish to avoid those two situations for now.

m.e.’s picture

Will watch out for #14. I've installed the 9/1 .dev version and as nearly as I can tell, my money problems are over! Thanks for digging into my site, @colemanw.

colemanw’s picture

Status: Active » Fixed

Glad to hear this is working for you.
I'm hoping that in the future this will be addressed in CiviCRM core and my workaround won't be necessary.

Status: Fixed » Closed (fixed)

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