Re: [web2py] Re: populate form in view

2015-08-26 Thread Jim Steil
Thanks for the correction Anthony, I didn't know that. -Jim On Wed, Aug 26, 2015 at 10:07 AM, Anthony wrote: > There's nothing wrong with calling .process() when the form is first > defined. Your code is exactly equivalent to the original. > > Anthony > > -- > Resources: > - http://web2py.com >

[web2py] Re: populate form in view

2015-08-26 Thread Anthony
There's nothing wrong with calling .process() when the form is first defined. Your code is exactly equivalent to the original. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/is

[web2py] Re: populate form in view

2015-08-26 Thread Jim S
I'm confused by the use of .process() at the end of your SQLFORM instantiation. Instead, I would do this: form = SQLFORM(db.certificate_request) if form.process().accepted: response.flash = 'new CSR registered' redirect(URL('customerArea', 'index') Hope that helps. -Jim On Tuesday, A

[web2py] Re: populate form in view

2015-08-25 Thread Iancic Bogdan
sure form = SQLFORM(db.certificate_request).process() if form.accepted: response.flash = 'new CSR registered' redirect(URL('customerArea','index')) On Tuesday, August 25, 2015 at 2:51:27 PM UTC+2, Jim S wrote: > > Can we see the form definition from your controller? > > -Jim >

[web2py] Re: populate form in view

2015-08-25 Thread Jim S
Can we see the form definition from your controller? -Jim On Tuesday, August 25, 2015 at 7:16:49 AM UTC-5, Iancic Bogdan wrote: > > I want to populate a form, besides the input that the user inserts. > > This is the code from view: > > var MattsPublicKeyString = cryptico.publicKeyString

[web2py] Re: populate form with just-submitted values

2014-11-07 Thread John Lofgren
Thanks very much, Leonel! I found that adding keepvalues=True as an argument to form.process() was what I needed. >>> if form.process(keepvalues=True).accepted: ... <<< John On Thursday, November 6, 2014 6:14:56 PM UTC-6, Leonel Câmara wrote: > > FORM has keepvalues=True, you can pass attri

[web2py] Re: populate form with just-submitted values

2014-11-06 Thread Leonel Câmara
FORM has keepvalues=True, you can pass attributes to SQLFORM or SQLFORM.factory and if they aren't options for SQLFORM they're passed to the form. So really all you have to do is add keepvalues=True. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread Anthony
Also, if admin users don't get added very often, you might consider caching the set of users so you don't need the queries on every request. Anthony On Tuesday, May 7, 2013 10:45:57 AM UTC-4, José Manuel López wrote: > > Hi Anthony, > Yes you are right, only 30 (because they say so :)). > Mayb

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread José Manuel López
Hi Anthony, Yes you are right, only 30 (because they say so :)). Maybe IS_IN_SET approach can work. I'll come back to copy the solution if I'm be able to make it work. Thank you very much for your time! On Tuesday, May 7, 2013 4:11:00 PM UTC+2, Anthony wrote: > > OK, then maybe: > > admin_users

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread Anthony
It is specific to GAE: https://developers.google.com/appengine/docs/python/datastore/projectionqueries On Tuesday, May 7, 2013 10:15:06 AM UTC-4, 黄祥 wrote: > > might i know what projection=

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread 黄祥
might i know what projection=True used for? thank you > > -- --- 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 op

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread Anthony
OK, then maybe: admin_users = db(db.auth_membership.group_id == auth.id_group('Admin'))\ .select(db.auth_membership.user_id, projection=True) ... requires=IS_IN_DB(db(db.auth_user.id.belongs([r.id for r in admin_users])), ...) I think GAE may limit the .belongs() to only 30 items,

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread José Manuel López
Thank you Anthony for your help, The problem now is this: Too many tables selected Can be a problem that I'm over GAE? On Tuesday, May 7, 2013 3:43:32 PM UTC+2, Anthony wrote: > > yes, you are right, db.auth_user will return all the users table. > > please try to change >> Field('hotel_chain_m

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread 黄祥
> He wants to limit the options shown in the dropdown, not set a single > default value (also, auth.has_membership() returns True/False, not a user > ID). > thanks for correct and explain to me, anthony best regards > -- --- You received this message because you are subscribed to the Goo

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread 黄祥
query = (db.Hotel.chainManager == auth.has_membership('Admin')) db.table.field.requires = IS_IN_DB(db(query), db.auth_user.id, '%(first_name)s %(last_name)s') not tested ref: http://web2py.com/books/default/chapter/29/07#Database-validators best regards On Tuesday, May 7, 2013 8:35:

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread Anthony
> > yes, you are right, db.auth_user will return all the users table. please try to change > Field('hotel_chain_manager', db.auth_user) > into > Field('hotel_chain_manager', 'reference auth_user', > default=auth.has_membership('Admin')) > He wants to limit the options shown in the dropdown, no

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread José Manuel López
It's not working for me :/ ... still the drop down list contains all the users On Tuesday, May 7, 2013 1:52:45 PM UTC+2, 黄祥 wrote: > > yes, you are right, db.auth_user will return all the users table. > please try to change > Field('hotel_chain_manager', db.auth_user) > into > Field('hotel_chain

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread 黄祥
yes, you are right, db.auth_user will return all the users table. please try to change Field('hotel_chain_manager', db.auth_user) into Field('hotel_chain_manager', 'reference auth_user', default=auth.has_membership('Admin')) hope this can help best regards On Tuesday, May 7, 2013 7:24:05 AM UT

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread José Manuel López
Hi!, Thank you for your answer, but it's not exactly what I want. I'll explain better: Let's say I have this table: db.define_table('Hotel', Field('name', label="Nombre del Hotel "), Field('hotel_type', db.BookingCategory), Field('h

[web2py] Re: Populate a field only with the admins

2013-05-07 Thread 黄祥
i think you can achieve it (in controller using grid) with editable = auth.has_membership('Admin') e.g. def booking(): has_membership=auth.has_membership('Admin') grid=SQLFORM.grid(db.booking, editable=has_membership) return locals() best regards On Tuesday, May 7, 2013 3:16:11 PM U

[web2py] Re: populate upload field type and store it in blob type field

2013-04-19 Thread 黄祥
> > it's a matter of "precedence". there's a clean section on the book on > how to do it > > http://web2py.com/books/default/chapter/29/06?search=More+on+uploads > > it's work well now, thank you so much for your pointer, niphlod. if db(db.test2).isempty(): stream = open('./applications/

[web2py] Re: populate upload field type and store it in blob type field

2013-04-19 Thread Niphlod
it's a matter of "precedence". there's a clean section on the book on how to do it http://web2py.com/books/default/chapter/29/06?search=More+on+uploads PS: you're importing populate from gluon.contrib but not using it: are you sure you need it ? On Friday, April 19, 2013 9:44:25 AM UTC+2,

[web2py] re populate

2011-10-11 Thread apple
Have just started using "populate" which is a really useful tool. However I have a couple of questions: 1) It seems to ignore the length specified for string fields. For example it fills my postcode field with 100 characters of text despite it having length of 8. Is there a way of restricting the

[web2py] Re: Populate a simple form (without a database)

2011-06-26 Thread Martin Weissenboeck
Thank you very much! Martin 2011/6/25 Anthony > First, I think you want FORM(INPUT(_name='n')), otherwise you'll have an > empty form. > > If you want to pre-populate a form using form.vars.fieldname=somevalue, you > have to do that after the form is created, but *before* you call > form.accepts

[web2py] Re: Populate a simple form (without a database)

2011-06-25 Thread Anthony
First, I think you want FORM(INPUT(_name='n')), otherwise you'll have an empty form. If you want to pre-populate a form using form.vars.fieldname=somevalue, you have to do that after the form is created, but *before* you call form.accepts (the form.accepts method adds the form.vars value to th

[web2py] Re: Populate a simple form (without a database)

2011-06-25 Thread Massimo Di Pierro
form=SQLFORM.factory(Field('n',default='MY DYNAMIC VALUE')) if form.acepts(request,session): redirect(URL('two)) retur dict(form=form) On Jun 25, 1:15 am, Martin Weissenboeck wrote: > Hi, > > let's say I have a simple form like the following: > > def one(): > > form = FORM(_name='n') > > if form.

[web2py] Re-populate Form after update

2011-03-02 Thread altuzzar
Hi. I'm new with Web2py and have a question. I have a table with a boolean, and the user can add or remove checkboxes. The table is updated with the new value, but I need my form re-populated so that it shows the changes. My code is the following: def sucursales(): records=db(db.auth_sucursa

[web2py] Re: Populate field based no other fields

2010-02-06 Thread mdipierro
You can also use with crud.create() crud.settings.create_onvalidation=lambda form: form.vars.update(field2=form.vars.field1) and crud.update() crud.settings.update_onvalidation=lambda form: form.vars.update(field2=form.vars.field1) or with SQLFORM from.accept(, onvalidation=lambda form: f

[web2py] Re: Populate field based no other fields

2010-02-05 Thread hywang
something like this def _compute(): return request.vars.in_time + request.vars.duration## db.define_table('mytable', Field('in_time','datetime'), Field('duration', 'integer'), Field('end_time','datetime', compute = _compute)) On Feb 5, 6:51 pm, Adi wrote: > Hi, > > I have a table with 3 fie

[web2py] Re: Populate field based on other fields

2010-02-05 Thread Adi
I meant datetime.timedelta not timeinterval. Sorry. On Feb 5, 3:51 pm, Adi wrote: > Hi, > > I have a table with 3 fields: > > db.define_table('mytable', Field('in_time','datetime'), > Field('duration', 'integer'), Field('end_time','datetime')) > > The user enters in_time and duration (in hours) i