Closed (fixed)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Feb 2012 at 05:31 UTC
Updated:
9 Aug 2012 at 04:01 UTC
Jump to comment: Most recent file
When filling out number components that are not required, if left blank the number component throws notices when viewing the result:
Warning: number_format() expects parameter 1 to be double, string given in _webform_number_format() (line 704 of /Users/nate/Sites/drupal7/sites/all/modules/webform/components/number.inc).
This is because an empty string is not a number and should not be run through number_format().
Additionally, if a field is empty, we probably shouldn't be outputting the field prefix/suffix, because it doesn't make much sense to have a floating $ or kgs with no value next to it. This patch fixes these display problems with empty strings.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | webform-number-format-1458330.patch | 508 bytes | liam morland |
| #1 | empty_number_display.patch | 1.42 KB | quicksketch |
| webform_hidden_type.patch | 2.28 KB | quicksketch |
Comments
Comment #1
quicksketchSorry wrong patch. Please ignore the original patch, which was for a different issue. Here it is.
Comment #2
quicksketchCommitted to both 3.x branches.
Comment #4
pederbennedsen commentedFixed in 3.16, but not in 3.18...
Comment #5
quicksketch@pederbennedsen: The fix is still clearly there in the code: http://drupalcode.org/project/webform.git/blob/refs/heads/7.x-3.x:/compo...
Are you sure you're running 3.18? What does it say on the Modules page your version is?
Comment #6
pederbennedsen commentedChecked the version on mudule page. It is 7.x-3.18.
Found the fix in number.inc. It is there. The size of the file is 24179 bytes.
But the error is still there, when a number field is not filled out:
Warning: number_format() expects parameter 1 to be double, string given in _webform_number_format() (line 703 of ...\sites\all\modules\webform\components\number.inc).
The number field is just a simple field with a name and no other attributes set.
Comment #7
liam morlandI am having this problem as well. Consider the attached fix.
Comment #8
liam morlandComment #9
bbdata commentedThe "Warning: number_format() expects parameter 1 to be double" error I also encounter when viewing node/*/webform-results/table
The patch from #7 resolves this problem.
Comment #10
acbramley commentedApplied patch #7 and it did fix the errors for me on the table display. There's also a very similar error when exporting a csv of results with empty number fields:
Opened issue #1690548: Warning: number_format() expects parameter 1 to be double, string given in _webform_csv_data_number() for this
Comment #11
acbramley commentedSimple patch and RTBC
Comment #12
quicksketchThanks guys, committed to 6.x-3.x, 7.x-3.x, and 7.x-4.x.