thanks everyone ... worked great

db.Party.partyTypeID.default = 1 ## just above where the function started

Alex

On Wednesday, April 17, 2013 8:10:12 AM UTC-7, Anthony wrote:
>
> def add_new_person():
>
> ##  form.vars.partyTypeID.default = 1    ########### tried this
>>
>
> The "form" variable doesn't even exist yet. Also, form vars are just 
> values, they are not DAL Field objects, so they do not have a "default" 
> attribute.
>  
>
>>     db.auth_user.partyID.readable = db.auth_user.partyID.writable = False 
>> ## don't let user see field thinking they have to fill it in
>>     db.Party.partyTypeID.readable = db.Party.partyTypeID.writable = False 
>> ## don't let user see field thinking they have to fill it in
>>
>
> Before creating the form, you can set the default value for the Field 
> object:
>
> db.Party.partyTypeID.default = 1
>  
>
>>     form=SQLFORM.factory(db.Party,db.auth_user)
>>     if form.process().accepted:
>>         partyID = db.Party.insert(**db.Party._filter_fields(form.vars))
>>         form.vars.partyID=partyID
>>         partyID = 
>> db.auth_user.insert(**db.auth_user._filter_fields(form.vars))
>> ##      form.element(_name='partyTypeID').update_record(_value=1)   
>> ########### 
>> tried this
>>
>
> form.element() searches the form HTML DOM and returns the INPUT() object 
> -- it is not a DAL Row object and therefore does not have an 
> update_record() method.
>  
>
>> ##      update_record(partyTypeID=1)   ########### tried this
>>
>
> That wouldn't work unless you had defined your own update_record() 
> function (and in any case, there's no indication of what is being updated).
>  
>
>> ##        form.vars.partyTypeID=1     ########### tried this
>>
>
> This should work, but as the book indicates, it should happen after the 
> form is created, but before it is processed.
>  
> Anthony
>

-- 

--- 
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