So I've managed to create myself a little bit of an interesting problem. I 
have a page that contains a form the user fills out. Before they submit it 
I use JQuery and check the form to make sure everything is filled out, and 
perform some saftey checks based on values they've filled in. Once they 
pass the checks, they submit the form and are brought to a page with 
another form. I use the previous form's POST data to fill in part of the 
new form. Everything displays nicely and the user can see what theyre about 
to submit into the database. The code I've included below is what generates 
and submits the second form.

@auth.requires_login()
def generate_mission():

# Save the mission profile based on the type
profile_info = get_profile()

if profile_info["profile"] == None: 


# Display the mission profile nice and pretty

db.profiles.mission.default = profile_info["profile"]

db.profiles.mission.represent = lambda v, r: XML(v.replace('\n', '<br />'))

db.profiles.mission.writable = False


# Create the SQL Form
form = SQLFORM(db.profiles,
        fields=['name', 'mission', 'user_id', 'profile_id'])

# Make the mission writable
db.profiles.mission.writable = True

# Process the form
if form.process().accepted:
    response.flash = "Added!"
    redirect(URL('my_floats', 'manage_profiles', vars={'id':session.id}))

 

# Return the form

 return dict(form=form)

 

The get_profile() function grabs the data from the first POST. By checking 
to see if profile_info["profile"] is None, I was attempting to prevent it 
from filling in the default a second time with zero values, but it seems 
that if I don't fill in the default, it ends up submitting NULL. My 
understanding was if I set something to default, it would carry over on the 
POST but it seems that is not the case. How would I go about keeping the 
data from the first time the function is called to when the form is 
submitted?

 

 


 


Reply via email to