Is there something else which needs to be setup to accomplish this?  I 
currently have...

db.define_table('brands',
    Field('brand_name', type='string', requires=IS_NOT_EMPTY(),
          label=T('Brand Name')),
    Field('active', type='boolean',
          label=T('active')))

form = SQLFORM(db.brands,hidden=dict(active=True))


However when the form is displayed the field ('active') still shows up 
visible.


On Monday, July 29, 2013 at 6:23:30 PM UTC-5, 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}}
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to