email field with "default value" "Disabled" (uneditable) and "Manditory" set fails to submit and clears that field

I want the user to SEE that their default email address is there, but I don't want them to change it. I could unset mandatory to allow it to pass, but the flag combination should still be possible, or it should be officially disabled, IMO.

Comments

quicksketch’s picture

Title: email field with "default value" "Disabled" (uneditable) and "Manditory" set fails to submit and clears that field » Fields with "Disabled" (uneditable) and "Manditory" fail to submit and clears that field
Status: Active » Fixed

Thanks, this also applied to textfields and textareas also. In Drupal 6 the "disabled" property actually destroys the submitted data (as if the field were empty). This follows suit with Firefox, that implement the standard that disabled fields actually shouldn't even be set in $_POST. So disable fields are pretty much totally broken.

I've committed the following changes to both Drupal 5 and 6 versions that switches the "disabled" property to "readonly", which pretty much accomplishes the same goal in that the user can't change the value, but they can still highlight/interact with the element. It also gets submitted properly.

Commit: http://drupal.org/cvs?commit=163961

Status: Fixed » Closed (fixed)

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

johnhanley’s picture

This bug report solved my dilemma (albeit unrelated to Webform) where the "disabled" attribute was clearing the field selection and causing the validation to fail.

I ended up using the "readonly" attribute, which accomplishes the same thing and satisfies validation because the field value is preserved upon submission.

Example:

$form['my_field']['#attributes'] = array('readonly' => 'readonly');