Is it possible to use on SQLFORM.grid?

Em quarta-feira, 18 de março de 2015 às 16:11:44 UTC-3, pumplerod escreveu:

> I tried that.  It doesn't work either.  I've worked around my issue by 
> simply not using hidden fields at all, but rather populating the fields 
> after the form is submitted with the data I want recorded.
>
>
> On Tuesday, March 17, 2015 at 12:42:53 PM UTC-5, Dave S wrote:
>>
>>
>>
>> On Tuesday, March 17, 2015 at 10:38:18 AM UTC-7, pumplerod wrote:
>>>
>>> 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.
>>>
>>>
>> The book doesn't have a detailed example at the referenced section 
>> (although details of what it is translated to are shown).
>>
>> Do you need quotes around the field name?  
>> hidden=dict("active"=True)
>> perhaps?
>>
>> /dps
>>
>>
>>
>>  
>>
>>>
>>> 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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/fa7ca2c5-1eaa-4877-8577-b29a254d51bbn%40googlegroups.com.

Reply via email to