I have the mother of all confusing form issues.  It seemed simple enough 
during the design phase...  (Don't they always??)

I have a table that contains registration information for this club.  It's 
a lengthy amount of data and it must be renewed annually.  I have a 
complete record of everyone's data from the last time they registered, and 
I want to use it to make their renewal easy.

My original data is in a table called "club_original" (not its real name, 
but I'm cleaning this up as I go along).  I also defined a table with 
exactly the same columns, plus a few more called "club_edit".  it is my 
intent to show the form populated with "club_original" data, then allow the 
user to change it willy-nilly, and when it validates save it into the 
"club_edit" table.  It sounds simple enough...

My idea is to use "form.validate()" to validate the fields on submission, 
then compute a few that are interdependent, and save it in the edit table. 
 The problem is these darned fields I want to calculate.  I've tried 
literally EVERYTHING to get this form to validate yet nothing works.  

Take the field "xyzzy" for example (not its real name).  It is a string 
field and it's not even needed on the form since i know its value from 
auth.user.  So I left it off the form thinking I could populate it either 
before or after displaying the form.  Well, I can't set its default before 
generating the form, because I didn't include it in the form itself, ergo, 
no place for the default value.  

No problemo, I thought, I'll just check for request.post_vars before the 
form is validated, and stuff the values in there ahead of validation. 
 Nope.  Apparently I can't do that because again the form doesn't have the 
field so the validate logic never sees it.

Aha!  I've got it!  I'll include the var name as a "hidden" var on the 
form.  It will show up in the fields as hidden, ride along to the browser, 
get returned with my value and all will be well.  Right?  Bzzzzt!  Thanks 
for playing, but no.  The hidden form won't fool the validator into 
accepting the form.

I feel like I'm so close to making this work, yet apparently not seeing 
some tree for the forest I'm wading through.  How do the black-belts handle 
this?

-- Joe

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to