When using the phone number component in a statefull form. The component will have no value when going back into the first step. My example has a multistep with preview values. Also the validation for the form accepts empty string even when the component is required.

Comments

ruudvanoijen created an issue. See original summary.

ruudvanoijen’s picture

Status: Active » Needs review
StatusFileSize
new2.44 KB

The patch

askibinski’s picture

Status: Needs review » Needs work

This line is undesirable:

+++ b/components/phone_number.inc
@@ -137,9 +137,11 @@ function _webform_render_phone_number($component, $value = NULL, $filter = TRUE)
+    $element['#value'] = $value[0];

The isset checks are nice, the other changes seem unnecessary.

The real problem is the return FALSE in dvg_webform_components_phone_number_value();

ruudvanoijen’s picture

Status: Needs work » Needs review
StatusFileSize
new2.4 KB

Fixed. Removed the false in the value callback. I've removed the element[#value]. The rest of the checks are improvements i've copied of the mail component from webform.

Danny.Wouters’s picture

Status: Needs review » Reviewed & tested by the community

The new patch looks good!
The additional changes in the patch are not directly linked to the original issue but I think they are good improvements

scuba_fly’s picture

Status: Reviewed & tested by the community » Needs work

I Applied the patch, but still if I step back trough the form, the phone number field is empty.

joshahubbers’s picture

StatusFileSize
new3.23 KB

New patch for latest version. The previous patch was already applied in the source.

This patch fixes the problem that an empty value was never validated as valid, even if the element was not required.

The value is preserved when you go "back" in the form.

joshahubbers’s picture

StatusFileSize
new3.51 KB

This patch is equal to the one in #7, but for the .9 version.

joshahubbers’s picture

Version: 7.x-1.0-beta6 » 7.x-1.0-beta9
Status: Needs work » Needs review
askibinski’s picture

Status: Needs review » Reviewed & tested by the community

Approved en tested in these cases:

* create webform with two pages
* place phone number field on page 1 - unrequired
* submit empty -> pass
* submit wrong value -> shows correct error
* submit correct value -> pass
* go step back from page 2, shows value in page 1
* make field required
* submit empty -> shows correct error

paulvandenburg’s picture

The #8 patch is made for dvg not this module.
The #7 patch does apply.

  • paulvandenburg committed 38ca8a1 on 7.x-1.x
    Issue #2926760 by ruudvanoijen, JoshaHubbers: Phone number component not...
paulvandenburg’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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