Hi,

I have the same issue. I added a checkbox to the form, but I can't get the 
value after submitting.

if request.args(0) == 'new':
        my_extra_element = DIV(LABEL('Create Remote SSH 
Key',_class="control-label 
col-sm-3"),INPUT(_name='create_key',_type='checkbox'), _class="form-group")
        form[1].insert(0,my_extra_element)

on_validation -> form.vars -> create_key is missing

Have you found a solution for that? 
Is there a better approach for adding a checkbox to a grid-form?

Thanks!
Raphael

On Wednesday, February 26, 2014 at 1:38:30 PM UTC+1, Maciej S wrote:
>
> Hi!
>
> I've created SQLFORM.grid like whowhywhat did. New elements have been 
> added to the form, but there is one drawback, if I submit, all data from 
> new fields is lost. What should I do to keep it during callbacks?
>
> Here is  my code:
> def users():   
>     grid = SQLFORM.grid(db.auth_user)
>     
>     if  len(request.args)>1 and request.args[-2]=='new' and grid.
> create_form:
>         grid.create_form[0].insert(-1,TR( LABEL('User type:', _id=
> 'auth_user_user_type'), INPUT(_type="radio", _name="radio_user_type", 
> _value="normal") + LABEL('Normal user', _id="auth_user_normal_user")))
>         grid.create_form[0].insert(-1,TR('', INPUT(_type="radio", _name=
> "radio_user_type", _value="service") + LABEL('Service user', _id=
> "auth_user_service_user")))
>         grid.create_form[0].insert(-1,TR('', INPUT(_type="radio", _name=
> "radio_user_type", _value="producer") + LABEL('Producer user', _id=
> "auth_user_producer_user")))
>
>     return grid
>
> Maciej
>
> W dniu piątek, 16 grudnia 2011 17:03:55 UTC+1 użytkownik whowhywhat 
> napisał:
>>
>> wow .. it works! :) ...
>>
>> i just added the following in the controller (after calling SQLFORM.grid):
>>
>> #check if form is a create form
>> if  len(request.args)>1 and request.args[-2]=='new' and form.create_form:
>>     my_extra_element = 
>> TR(LABEL('Married'),INPUT(_name='married',value=False,_type='checkbox'))
>>     form.create_form[0].insert(-1,my_extra_element)
>>
>> now i need to add some jquery in the view (again after checking if the 
>> view is for a create or edit form).. this is so cool :D ..
>> thanks a lot Anthony!
>>
>> will post a full example later..
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to