Well, thank you very much lesssugar, adding to my controller did indeed 
work, so at least i can move forward now;)
For anyone else, this is what worked:
    form = SQLFORM(db.games, hidden=dict(status="active"))

On Monday, July 29, 2013 7:23:30 PM UTC-4, lesssugar wrote:
>
> Take a look at the book: 
> http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=hidden+fields#Hidden-fields
>
> You can try defining your hidden field with *hidden *attribute:
>
> SQLFORM(..., hidden=dict(hidden_field_name=hidden_field_value))
>
> It should work.
>
> On Monday, July 29, 2013 6:47:01 AM UTC+2, davedigerati wrote:
>>
>> I've succeeded in using a custom SQLFORM to restrict how many fields of a 
>> table the user has to fill out, but now I am trying to set a hidden field 
>> value (status) and struggling.
>>
>> I tried in the model to use:
>>     form = SQLFORM(db.games)
>>     form.vars.status = 'active'
>>
>> but the field never gets written to the db, I believe because it is not 
>> one of the fields declared in html (below).
>>
>> I then tried through the html as 
>> {{form.vars.status = 'active'}}
>> but while it was in the Accepted form.vars, it doesn't show up in 
>> request.vars and again, doesn't get written.
>>
>> So, okay, let's place it in the html as 
>> {{request.vars.status = 'active'}}
>> And now it gets into request.vars, but again is not written to the db.
>>  
>> I think I've sunk over my head on this one, and advice correcting my 
>> approach above would be greatly appreciated.
>> Or was this a bad path to start down and I should just use a separate 
>> operation to write this field to the table after the record is created?
>> Thanks,
>> Dave
>>
>> html if it helps:
>> {{=form.custom.begin}}
>> {{form.custom.widget.tm_home["_placeholder"] = "Home Team Name"}}
>> {{=form.custom.widget.tm_home}}
>> {{request.vars.status = "active"}}   <---  tried variations of this line 
>> & without it
>> {{=form.custom.submit}}
>> {{=form.custom.end}}
>>
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to