views:

18

answers:

1

My form has a bunch of address fields (street, city, country, province, postal code) that need to be filled out over and over again. To make it easier for the user, I've added a "copy from" selector where they can choose an address they've previously used. When they do this, the form fields are filled in automatically and then disabled. This way they can clearly see what they're about to submit.

The problem is, if the fields are disabled, W3 says the inputs won't be submitted. That would be fine, because I can get all the data I need from the selector, except that now the form fails validation.

I figure I have two options:

  1. Re-enable the form fields just before submitting the form (but this is a bit of hack)
  2. Make all the address fields optional. But then I need to add a bunch of clean_ methods to make sure they actually are filled in when you don't use the preset selector. Also, I'm using the address form all over the site, and in some places they truly are required, so I'd prefer not to make the fields optional. Although, I guess I could just copy-paste the address form and make a special case for this page.

Thoughts? What approach should I take?

+1  A: 

A couple of thoughts. They might give you some ideas.

  1. If the users are using an address they have previously used and they cannot edit the form (fields are disabled), do they need an address form at all? Can you not display the previous address without a form and pass a reference to it as a hidden parameter?
  2. If the users can edit the previously selected address (I think Amazon does this) then wouldn't it make sense to leave the form fields editable?
Manoj Govindan
(1) Yes. The address form is already there.. they can skip past the presets and just start filling it out; it doesn't make sense to force them to look at the presets to decide whether or not they want to use it and then make it appear... plus a 1-line address isn't as clear as separating out the parts as the form does; having the disabled elements is easier to read. (2) No. The address is saved into a separate table; I want the fields disabled so that I know if I can re-use the same FK or if have to create a new address object. If they want to use a preset *and then* edit it, they can click---
Mark
-- the preset, then flip back to the "- Select -" option to re-enable the inputs but keep the values, then edit it to their hearts content.
Mark