[web2py] Re: Custom form errors style
Hi, This did the trick. Thank you very much!! El viernes, 23 de agosto de 2019, 10:09:01 (UTC-5), Annet escribió: > > To diasble it: > > if form.accepts(..., hideerror=False): > > > to restyle it, restyle: > > .error > > > Kind regards, > > Annet > > -- 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/211c6995-a634-413d-9211-b832d07fc615%40googlegroups.com.
[web2py] Re: Custom form errors style
To diasble it: if form.accepts(..., hideerror=False): to restyle it, restyle: .error Kind regards, Annet -- 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/b476d921-e78d-4d96-9962-b6601bc6791a%40googlegroups.com.
[web2py] Re: custom form web2py not work when i use selectpicker
It seems selectpicker is causing a change in what gets sent to web2py. In the browser developer tools, can you check what form data gets sent to the server with and without selectpicker enabled? Maybe that will provide a clue. Anthony On Tuesday, August 21, 2018 at 4:42:30 PM UTC-4, Rodrigo Gomes wrote: > > jim, thank you for you time, what is causing the error is, if i use > {{=form}} my code works, but if i use the form.custom as you suggested, my > code not work, if i > remove form.element(_id='no_table_cities').update(_class='selectpicker') in > my controller, form custom work again, so i have not idea about what is > goin on here, > > iam using my own custom html, because, form custom, and form, generate > much bootstrap classes betwen my code, and iam using a custom theme, This > is a bit of a problem, I like to have control in my hands, since I > identified that web2py identifies my inputs by the id and name of the > element, I have not used it the old way. > > I think it is well related to selectpicker, because if I use any other > class besides this, it does not interfere with the capture of my select data > > terça-feira, 21 de Agosto de 2018 às 17:07:23 UTC-3, Jim S escreveu: >> >> Ok, now that we know the problem isn't with SQLFORM.factory lets look >> closer at the generated html when using {{=form}} vs the html you typed in. >> >> Specifically: >> >> > name="address_type" data-style="btn-info btn-outline-info"> >> >> {{for t in address_type_list:}} >> {{=t.type}} >> {{pass}} >> >> >> I'm curious why you're using your own custom html instead of using the >> custom form technique. >> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms >> >> {{=form.custom.begin}} >> {{=form.custom.widget.name}} >> {{=form.custom.widget.cpf}} >> {{=form.custom.widget.email}} >> {{=form.custom.widget.address_type}} >> {{=form.custom.widget.cities}} >> {{=form.custom.widget.person}} >> {{=form.custom.submit}} >> {{=form.custom.end}} >> >> Good luck >> >> -Jim >> >> On Tuesday, August 21, 2018 at 2:57:33 PM UTC-5, Rodrigo Gomes wrote: >>> >>> I just tested with {{= form}} and it really worked, so the problem is >>> between >>> >>> >> method="post"> >>> >>> >> >> >> >> >>> {{=form.hidden_fields()}} >>> >>> >>> >>> >>> >>> >>> >>> >>> terça-feira, 21 de Agosto de 2018 às 13:46:55 UTC-3, Jim S escreveu: Have you tried just displaying the form in your view using {{=form}}. Then add a requires=IS_IN_DB to the fields in your model. I'd do this just to make sure that SQLFORM.factory is working as expected. Make sense? http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators -Jim On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote: > > i really think its a bug in form.factory, i tried modify by the > controller too, like > form.element(_id=no_table_cities).update(_class="selectpicker") > > and no sucess. > > terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes > escreveu: >> >> @auth.requires_login() >> def students(): >> form = form=SQLFORM.factory(db.person, db.address) >> >> cities_list = db(db.cities.id>0).select(db.cities.ALL) >> address_type_list = db(db.address_type.id>0 >> ).select(db.address_type.ALL) >> person_list = db(db.person.id>0).select(db.person.ALL) >> >> >> if form.process().accepted: >> id = db.person.insert(**db.person._filter_fields(form.vars)) >> form.vars.person=id >> id = db.address.insert(**db.address._filter_fields(form.vars)) >> redirect(URL('default','students')) >> response.flash='Form Submetido com sucesso!' >> elif form.errors: >> print(form.errors) >> print(form.vars) >> else: >> print('please fill out the form') >> return dict(form=form, cities_list=cities_list, >> address_type_list=address_type_list, >> person_list=person_list) >> >> >> terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang >> escreveu: >>> >>> How did you define your cities_list? >>> >>> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes >>> wrote: Good evening, folks, I've come here to unveil a mystery, I'm developing an application with web2py, (framework that I use about 3 years ago) I am using sqlform.factory, passing 2 tables, being that I do this to fill in a single form, table, person and address, for better understanding follows my controller, @auth.requires_login() def students(): form = form=SQLFORM.factory(db.person, db.address) if form.process().accepted:
[web2py] Re: custom form web2py not work when i use selectpicker
Did you include all the necessary files? .selectpicker() is a function defined under bootstrap-select lib and not in core bootstrap library,hence you need to include that library as well //silviomoreto.github.io/bootstrap-select/javascripts/bootstrap-select.js //silviomoreto.github.io/bootstrap-select/stylesheets/bootstrap-select.css HTML: All Businesses Events News Lifestyle JQUERY CODE: $('.selectpicker').selectpicker(); On Tuesday, August 21, 2018 at 1:42:30 PM UTC-7, Rodrigo Gomes wrote: > > jim, thank you for you time, what is causing the error is, if i use > {{=form}} my code works, but if i use the form.custom as you suggested, my > code not work, if i > remove form.element(_id='no_table_cities').update(_class='selectpicker') in > my controller, form custom work again, so i have not idea about what is > goin on here, > > iam using my own custom html, because, form custom, and form, generate > much bootstrap classes betwen my code, and iam using a custom theme, This > is a bit of a problem, I like to have control in my hands, since I > identified that web2py identifies my inputs by the id and name of the > element, I have not used it the old way. > > I think it is well related to selectpicker, because if I use any other > class besides this, it does not interfere with the capture of my select data > > terça-feira, 21 de Agosto de 2018 às 17:07:23 UTC-3, Jim S escreveu: >> >> Ok, now that we know the problem isn't with SQLFORM.factory lets look >> closer at the generated html when using {{=form}} vs the html you typed in. >> >> Specifically: >> >> > name="address_type" data-style="btn-info btn-outline-info"> >> >> {{for t in address_type_list:}} >> {{=t.type}} >> {{pass}} >> >> >> I'm curious why you're using your own custom html instead of using the >> custom form technique. >> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms >> >> {{=form.custom.begin}} >> {{=form.custom.widget.name}} >> {{=form.custom.widget.cpf}} >> {{=form.custom.widget.email}} >> {{=form.custom.widget.address_type}} >> {{=form.custom.widget.cities}} >> {{=form.custom.widget.person}} >> {{=form.custom.submit}} >> {{=form.custom.end}} >> >> Good luck >> >> -Jim >> >> On Tuesday, August 21, 2018 at 2:57:33 PM UTC-5, Rodrigo Gomes wrote: >>> >>> I just tested with {{= form}} and it really worked, so the problem is >>> between >>> >>> >> method="post"> >>> >>> >> >> >> >> >>> {{=form.hidden_fields()}} >>> >>> >>> >>> >>> >>> >>> >>> >>> terça-feira, 21 de Agosto de 2018 às 13:46:55 UTC-3, Jim S escreveu: Have you tried just displaying the form in your view using {{=form}}. Then add a requires=IS_IN_DB to the fields in your model. I'd do this just to make sure that SQLFORM.factory is working as expected. Make sense? http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators -Jim On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote: > > i really think its a bug in form.factory, i tried modify by the > controller too, like > form.element(_id=no_table_cities).update(_class="selectpicker") > > and no sucess. > > terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes > escreveu: >> >> @auth.requires_login() >> def students(): >> form = form=SQLFORM.factory(db.person, db.address) >> >> cities_list = db(db.cities.id>0).select(db.cities.ALL) >> address_type_list = db(db.address_type.id>0 >> ).select(db.address_type.ALL) >> person_list = db(db.person.id>0).select(db.person.ALL) >> >> >> if form.process().accepted: >> id = db.person.insert(**db.person._filter_fields(form.vars)) >> form.vars.person=id >> id = db.address.insert(**db.address._filter_fields(form.vars)) >> redirect(URL('default','students')) >> response.flash='Form Submetido com sucesso!' >> elif form.errors: >> print(form.errors) >> print(form.vars) >> else: >> print('please fill out the form') >> return dict(form=form, cities_list=cities_list, >> address_type_list=address_type_list, >> person_list=person_list) >> >> >> terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang >> escreveu: >>> >>> How did you define your cities_list? >>> >>> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes >>> wrote: Good evening, folks, I've come here to unveil a mystery, I'm developing an application with web2py, (framework that I use about 3 years ago) I am using sqlform.factory, passing 2 tables, being that I do this to fill in a single form, table, person and address, for better understanding follows my
[web2py] Re: custom form web2py not work when i use selectpicker
I'm not aware of 'selectpicker'. What does it offer that the default select widget doesn't? I'm guessing you're also aware that you can override all of that bootstrap form style by creating your own formstyle and specifying it on SQLFORM.factory(formstyle=my_formstyle) call. I'm not sure if this helps but just thought I'd mention it. -Jim On Tuesday, August 21, 2018 at 3:42:30 PM UTC-5, Rodrigo Gomes wrote: > > jim, thank you for you time, what is causing the error is, if i use > {{=form}} my code works, but if i use the form.custom as you suggested, my > code not work, if i > remove form.element(_id='no_table_cities').update(_class='selectpicker') in > my controller, form custom work again, so i have not idea about what is > goin on here, > > iam using my own custom html, because, form custom, and form, generate > much bootstrap classes betwen my code, and iam using a custom theme, This > is a bit of a problem, I like to have control in my hands, since I > identified that web2py identifies my inputs by the id and name of the > element, I have not used it the old way. > > I think it is well related to selectpicker, because if I use any other > class besides this, it does not interfere with the capture of my select data > > terça-feira, 21 de Agosto de 2018 às 17:07:23 UTC-3, Jim S escreveu: >> >> Ok, now that we know the problem isn't with SQLFORM.factory lets look >> closer at the generated html when using {{=form}} vs the html you typed in. >> >> Specifically: >> >> > name="address_type" data-style="btn-info btn-outline-info"> >> >> {{for t in address_type_list:}} >> {{=t.type}} >> {{pass}} >> >> >> I'm curious why you're using your own custom html instead of using the >> custom form technique. >> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms >> >> {{=form.custom.begin}} >> {{=form.custom.widget.name}} >> {{=form.custom.widget.cpf}} >> {{=form.custom.widget.email}} >> {{=form.custom.widget.address_type}} >> {{=form.custom.widget.cities}} >> {{=form.custom.widget.person}} >> {{=form.custom.submit}} >> {{=form.custom.end}} >> >> Good luck >> >> -Jim >> >> On Tuesday, August 21, 2018 at 2:57:33 PM UTC-5, Rodrigo Gomes wrote: >>> >>> I just tested with {{= form}} and it really worked, so the problem is >>> between >>> >>> >> method="post"> >>> >>> >> >> >> >> >>> {{=form.hidden_fields()}} >>> >>> >>> >>> >>> >>> >>> >>> >>> terça-feira, 21 de Agosto de 2018 às 13:46:55 UTC-3, Jim S escreveu: Have you tried just displaying the form in your view using {{=form}}. Then add a requires=IS_IN_DB to the fields in your model. I'd do this just to make sure that SQLFORM.factory is working as expected. Make sense? http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators -Jim On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote: > > i really think its a bug in form.factory, i tried modify by the > controller too, like > form.element(_id=no_table_cities).update(_class="selectpicker") > > and no sucess. > > terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes > escreveu: >> >> @auth.requires_login() >> def students(): >> form = form=SQLFORM.factory(db.person, db.address) >> >> cities_list = db(db.cities.id>0).select(db.cities.ALL) >> address_type_list = db(db.address_type.id>0 >> ).select(db.address_type.ALL) >> person_list = db(db.person.id>0).select(db.person.ALL) >> >> >> if form.process().accepted: >> id = db.person.insert(**db.person._filter_fields(form.vars)) >> form.vars.person=id >> id = db.address.insert(**db.address._filter_fields(form.vars)) >> redirect(URL('default','students')) >> response.flash='Form Submetido com sucesso!' >> elif form.errors: >> print(form.errors) >> print(form.vars) >> else: >> print('please fill out the form') >> return dict(form=form, cities_list=cities_list, >> address_type_list=address_type_list, >> person_list=person_list) >> >> >> terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang >> escreveu: >>> >>> How did you define your cities_list? >>> >>> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes >>> wrote: Good evening, folks, I've come here to unveil a mystery, I'm developing an application with web2py, (framework that I use about 3 years ago) I am using sqlform.factory, passing 2 tables, being that I do this to fill in a single form, table, person and address, for better understanding follows my controller, @auth.requires_login() def students(): form =
[web2py] Re: custom form web2py not work when i use selectpicker
jim, thank you for you time, what is causing the error is, if i use {{=form}} my code works, but if i use the form.custom, my code not work, if i remove form.element(_id='no_table_cities').update(_class='selectpicker') in my controller, form custom work again, so i have not idea about what is goin on here, iam using my own custom html, because, form custom, and form, generate much bootstrap classes betwen my code, and iam using a custom theme, This is a bit of a problem, I like to have control in my hands, since I identified that web2py identifies my inputs by the id and name of the element, I have not used it the old way. I think it is well related to selectpicker, because if I use any other class besides this, it does not interfere with the capture of my select data terça-feira, 21 de Agosto de 2018 às 17:07:23 UTC-3, Jim S escreveu: > > Ok, now that we know the problem isn't with SQLFORM.factory lets look > closer at the generated html when using {{=form}} vs the html you typed in. > > Specifically: > > name="address_type" data-style="btn-info btn-outline-info"> > > {{for t in address_type_list:}} > {{=t.type}} > {{pass}} > > > I'm curious why you're using your own custom html instead of using the > custom form technique. > http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms > > {{=form.custom.begin}} > {{=form.custom.widget.name}} > {{=form.custom.widget.cpf}} > {{=form.custom.widget.email}} > {{=form.custom.widget.address_type}} > {{=form.custom.widget.cities}} > {{=form.custom.widget.person}} > {{=form.custom.submit}} > {{=form.custom.end}} > > Good luck > > -Jim > > On Tuesday, August 21, 2018 at 2:57:33 PM UTC-5, Rodrigo Gomes wrote: >> >> I just tested with {{= form}} and it really worked, so the problem is >> between >> >> > method="post"> >> >> > > > > >> {{=form.hidden_fields()}} >> >> >> >> >> >> >> >> >> terça-feira, 21 de Agosto de 2018 às 13:46:55 UTC-3, Jim S escreveu: >>> >>> Have you tried just displaying the form in your view using {{=form}}. >>> Then add a requires=IS_IN_DB to the fields in your model. I'd do this just >>> to make sure that SQLFORM.factory is working as expected. Make sense? >>> >>> >>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators >>> >>> -Jim >>> >>> On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote: i really think its a bug in form.factory, i tried modify by the controller too, like form.element(_id=no_table_cities).update(_class="selectpicker") and no sucess. terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes escreveu: > > @auth.requires_login() > def students(): > form = form=SQLFORM.factory(db.person, db.address) > > cities_list = db(db.cities.id>0).select(db.cities.ALL) > address_type_list = db(db.address_type.id>0 > ).select(db.address_type.ALL) > person_list = db(db.person.id>0).select(db.person.ALL) > > > if form.process().accepted: > id = db.person.insert(**db.person._filter_fields(form.vars)) > form.vars.person=id > id = db.address.insert(**db.address._filter_fields(form.vars)) > redirect(URL('default','students')) > response.flash='Form Submetido com sucesso!' > elif form.errors: > print(form.errors) > print(form.vars) > else: > print('please fill out the form') > return dict(form=form, cities_list=cities_list, > address_type_list=address_type_list, > person_list=person_list) > > > terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang > escreveu: >> >> How did you define your cities_list? >> >> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote: >>> >>> >>> Good evening, folks, I've come here to unveil a mystery, I'm >>> developing an application with web2py, (framework that I use about 3 >>> years >>> ago) >>> >>> I am using sqlform.factory, passing 2 tables, being that I do this >>> to fill in a single form, table, person and address, for better >>> understanding follows my controller, >>> >>> >>> @auth.requires_login() >>> def students(): >>> form = form=SQLFORM.factory(db.person, db.address) >>> >>> if form.process().accepted: >>>id = db.person.insert(**db.person._filter_fields(form.vars)) >>>form.vars.person=id >>>id = db.address.insert(**db.address._filter_fields(form.vars)) >>>response.flash='Form Submetido com sucesso!' >>> >>> elif form.errors: >>>print(form.errors) >>> else: >>>print('please fill out the form') >>> >>> >>> >>> >>> if it helps, this is my model, the tables and their relationships, >>> >>>
[web2py] Re: custom form web2py not work when i use selectpicker
Ok, now that we know the problem isn't with SQLFORM.factory lets look closer at the generated html when using {{=form}} vs the html you typed in. Specifically: {{for t in address_type_list:}} {{=t.type}} {{pass}} I'm curious why you're using your own custom html instead of using the custom form technique. http://web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-forms {{=form.custom.begin}} {{=form.custom.widget.name}} {{=form.custom.widget.cpf}} {{=form.custom.widget.email}} {{=form.custom.widget.address_type}} {{=form.custom.widget.cities}} {{=form.custom.widget.person}} {{=form.custom.submit}} {{=form.custom.end}} Good luck -Jim On Tuesday, August 21, 2018 at 2:57:33 PM UTC-5, Rodrigo Gomes wrote: > > I just tested with {{= form}} and it really worked, so the problem is > between > > method="post"> > > > {{=form.hidden_fields()}} > > > > > > > > > terça-feira, 21 de Agosto de 2018 às 13:46:55 UTC-3, Jim S escreveu: >> >> Have you tried just displaying the form in your view using {{=form}}. >> Then add a requires=IS_IN_DB to the fields in your model. I'd do this just >> to make sure that SQLFORM.factory is working as expected. Make sense? >> >> >> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators >> >> -Jim >> >> On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote: >>> >>> i really think its a bug in form.factory, i tried modify by the >>> controller too, like >>> form.element(_id=no_table_cities).update(_class="selectpicker") >>> >>> and no sucess. >>> >>> terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes >>> escreveu: @auth.requires_login() def students(): form = form=SQLFORM.factory(db.person, db.address) cities_list = db(db.cities.id>0).select(db.cities.ALL) address_type_list = db(db.address_type.id>0 ).select(db.address_type.ALL) person_list = db(db.person.id>0).select(db.person.ALL) if form.process().accepted: id = db.person.insert(**db.person._filter_fields(form.vars)) form.vars.person=id id = db.address.insert(**db.address._filter_fields(form.vars)) redirect(URL('default','students')) response.flash='Form Submetido com sucesso!' elif form.errors: print(form.errors) print(form.vars) else: print('please fill out the form') return dict(form=form, cities_list=cities_list, address_type_list=address_type_list, person_list=person_list) terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang escreveu: > > How did you define your cities_list? > > On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote: >> >> >> Good evening, folks, I've come here to unveil a mystery, I'm >> developing an application with web2py, (framework that I use about 3 >> years >> ago) >> >> I am using sqlform.factory, passing 2 tables, being that I do this to >> fill in a single form, table, person and address, for better >> understanding >> follows my controller, >> >> >> @auth.requires_login() >> def students(): >> form = form=SQLFORM.factory(db.person, db.address) >> >> if form.process().accepted: >>id = db.person.insert(**db.person._filter_fields(form.vars)) >>form.vars.person=id >>id = db.address.insert(**db.address._filter_fields(form.vars)) >>response.flash='Form Submetido com sucesso!' >> >> elif form.errors: >>print(form.errors) >> else: >>print('please fill out the form') >> >> >> >> >> if it helps, this is my model, the tables and their relationships, >> >> db.define_table("person", >> Field("name", "string", length=50), >> Field("cpf", "string", length=11), >> Field("birthday", "date", length=11), >> Field("email","string", length=40), >> Field("registration_date","date", length=40) >> ) >> >> db.define_table("cities", >> Field("name", "string"), >> Field("state","reference state") >> ) >> >> db.define_table("address_type", >> Field("type","string",length=100), >> ) >> >> db.define_table("address", >> Field("number","integer"), >> Field("public_place","string"), >> Field("cep","string",length=15), >> Field("complement","string"), >> Field("cities",'reference cities'), >> Field("address_type",'reference address_type'), >> Field("person",'reference person', writable=False,readable=False) >> ) >> >> >> >> >> This is my view >> >> > method="post"> >> >> >> >>
[web2py] Re: custom form web2py not work when i use selectpicker
I just tested with {{= form}} and it really worked, so the problem is between {{=form.hidden_fields()}} terça-feira, 21 de Agosto de 2018 às 13:46:55 UTC-3, Jim S escreveu: > > Have you tried just displaying the form in your view using {{=form}}. > Then add a requires=IS_IN_DB to the fields in your model. I'd do this just > to make sure that SQLFORM.factory is working as expected. Make sense? > > > http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators > > -Jim > > On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote: >> >> i really think its a bug in form.factory, i tried modify by the >> controller too, like >> form.element(_id=no_table_cities).update(_class="selectpicker") >> >> and no sucess. >> >> terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes >> escreveu: >>> >>> @auth.requires_login() >>> def students(): >>> form = form=SQLFORM.factory(db.person, db.address) >>> >>> cities_list = db(db.cities.id>0).select(db.cities.ALL) >>> address_type_list = db(db.address_type.id>0).select(db.address_type.ALL) >>> person_list = db(db.person.id>0).select(db.person.ALL) >>> >>> >>> if form.process().accepted: >>> id = db.person.insert(**db.person._filter_fields(form.vars)) >>> form.vars.person=id >>> id = db.address.insert(**db.address._filter_fields(form.vars)) >>> redirect(URL('default','students')) >>> response.flash='Form Submetido com sucesso!' >>> elif form.errors: >>> print(form.errors) >>> print(form.vars) >>> else: >>> print('please fill out the form') >>> return dict(form=form, cities_list=cities_list, >>> address_type_list=address_type_list, >>> person_list=person_list) >>> >>> >>> terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang escreveu: How did you define your cities_list? On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote: > > > Good evening, folks, I've come here to unveil a mystery, I'm > developing an application with web2py, (framework that I use about 3 > years > ago) > > I am using sqlform.factory, passing 2 tables, being that I do this to > fill in a single form, table, person and address, for better > understanding > follows my controller, > > > @auth.requires_login() > def students(): > form = form=SQLFORM.factory(db.person, db.address) > > if form.process().accepted: >id = db.person.insert(**db.person._filter_fields(form.vars)) >form.vars.person=id >id = db.address.insert(**db.address._filter_fields(form.vars)) >response.flash='Form Submetido com sucesso!' > > elif form.errors: >print(form.errors) > else: >print('please fill out the form') > > > > > if it helps, this is my model, the tables and their relationships, > > db.define_table("person", > Field("name", "string", length=50), > Field("cpf", "string", length=11), > Field("birthday", "date", length=11), > Field("email","string", length=40), > Field("registration_date","date", length=40) > ) > > db.define_table("cities", > Field("name", "string"), > Field("state","reference state") > ) > > db.define_table("address_type", > Field("type","string",length=100), > ) > > db.define_table("address", > Field("number","integer"), > Field("public_place","string"), > Field("cep","string",length=15), > Field("complement","string"), > Field("cities",'reference cities'), > Field("address_type",'reference address_type'), > Field("person",'reference person', writable=False,readable=False) > ) > > > > > This is my view > > method="post"> > > > > name="name" type="text" placeholder="nome"> > > > > type="text" placeholder="cpf"> > > > > > name="email" type="text" placeholder="email"> > > > > > > id="no_table_address_type" name="address_type" data-style="btn-info > btn-outline-info"> > > {{for t in address_type_list:}} > {{=t.type}} > {{pass}} > > > > data-style="btn-info btn-outline-info" required> > {{for city in
[web2py] Re: custom form web2py not work when i use selectpicker
Have you tried just displaying the form in your view using {{=form}}. Then add a requires=IS_IN_DB to the fields in your model. I'd do this just to make sure that SQLFORM.factory is working as expected. Make sense? http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators -Jim On Tuesday, August 21, 2018 at 11:34:23 AM UTC-5, Rodrigo Gomes wrote: > > i really think its a bug in form.factory, i tried modify by the controller > too, like > form.element(_id=no_table_cities).update(_class="selectpicker") > > and no sucess. > > terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes > escreveu: >> >> @auth.requires_login() >> def students(): >> form = form=SQLFORM.factory(db.person, db.address) >> >> cities_list = db(db.cities.id>0).select(db.cities.ALL) >> address_type_list = db(db.address_type.id>0).select(db.address_type.ALL) >> person_list = db(db.person.id>0).select(db.person.ALL) >> >> >> if form.process().accepted: >> id = db.person.insert(**db.person._filter_fields(form.vars)) >> form.vars.person=id >> id = db.address.insert(**db.address._filter_fields(form.vars)) >> redirect(URL('default','students')) >> response.flash='Form Submetido com sucesso!' >> elif form.errors: >> print(form.errors) >> print(form.vars) >> else: >> print('please fill out the form') >> return dict(form=form, cities_list=cities_list, >> address_type_list=address_type_list, >> person_list=person_list) >> >> >> terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang escreveu: >>> >>> How did you define your cities_list? >>> >>> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote: Good evening, folks, I've come here to unveil a mystery, I'm developing an application with web2py, (framework that I use about 3 years ago) I am using sqlform.factory, passing 2 tables, being that I do this to fill in a single form, table, person and address, for better understanding follows my controller, @auth.requires_login() def students(): form = form=SQLFORM.factory(db.person, db.address) if form.process().accepted: id = db.person.insert(**db.person._filter_fields(form.vars)) form.vars.person=id id = db.address.insert(**db.address._filter_fields(form.vars)) response.flash='Form Submetido com sucesso!' elif form.errors: print(form.errors) else: print('please fill out the form') if it helps, this is my model, the tables and their relationships, db.define_table("person", Field("name", "string", length=50), Field("cpf", "string", length=11), Field("birthday", "date", length=11), Field("email","string", length=40), Field("registration_date","date", length=40) ) db.define_table("cities", Field("name", "string"), Field("state","reference state") ) db.define_table("address_type", Field("type","string",length=100), ) db.define_table("address", Field("number","integer"), Field("public_place","string"), Field("cep","string",length=15), Field("complement","string"), Field("cities",'reference cities'), Field("address_type",'reference address_type'), Field("person",'reference person', writable=False,readable=False) ) This is my view >>> method="post"> >>> type="text" placeholder="nome"> >>> type="text" placeholder="cpf"> >>> name="email" type="text" placeholder="email"> >>> id="no_table_address_type" name="address_type" data-style="btn-info btn-outline-info"> {{for t in address_type_list:}} {{=t.type}} {{pass}} >>> data-style="btn-info btn-outline-info" required> {{for city in cities_list:}} {{=city.name}} {{pass}} {{=form.hidden_fields()}} >>> data-dismiss="modal">Cancelar
[web2py] Re: custom form web2py not work when i use selectpicker
i really think its a bug in form.factory, i tried modify by the controller too, like form.element(_id=no_table_cities).update(_class="selectpicker") and no sucess. terça-feira, 21 de Agosto de 2018 às 13:31:38 UTC-3, Rodrigo Gomes escreveu: > > @auth.requires_login() > def students(): > form = form=SQLFORM.factory(db.person, db.address) > > cities_list = db(db.cities.id>0).select(db.cities.ALL) > address_type_list = db(db.address_type.id>0).select(db.address_type.ALL) > person_list = db(db.person.id>0).select(db.person.ALL) > > > if form.process().accepted: > id = db.person.insert(**db.person._filter_fields(form.vars)) > form.vars.person=id > id = db.address.insert(**db.address._filter_fields(form.vars)) > redirect(URL('default','students')) > response.flash='Form Submetido com sucesso!' > elif form.errors: > print(form.errors) > print(form.vars) > else: > print('please fill out the form') > return dict(form=form, cities_list=cities_list, > address_type_list=address_type_list, > person_list=person_list) > > > terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang escreveu: >> >> How did you define your cities_list? >> >> On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote: >>> >>> >>> Good evening, folks, I've come here to unveil a mystery, I'm developing >>> an application with web2py, (framework that I use about 3 years ago) >>> >>> I am using sqlform.factory, passing 2 tables, being that I do this to >>> fill in a single form, table, person and address, for better understanding >>> follows my controller, >>> >>> >>> @auth.requires_login() >>> def students(): >>> form = form=SQLFORM.factory(db.person, db.address) >>> >>> if form.process().accepted: >>>id = db.person.insert(**db.person._filter_fields(form.vars)) >>>form.vars.person=id >>>id = db.address.insert(**db.address._filter_fields(form.vars)) >>>response.flash='Form Submetido com sucesso!' >>> >>> elif form.errors: >>>print(form.errors) >>> else: >>>print('please fill out the form') >>> >>> >>> >>> >>> if it helps, this is my model, the tables and their relationships, >>> >>> db.define_table("person", >>> Field("name", "string", length=50), >>> Field("cpf", "string", length=11), >>> Field("birthday", "date", length=11), >>> Field("email","string", length=40), >>> Field("registration_date","date", length=40) >>> ) >>> >>> db.define_table("cities", >>> Field("name", "string"), >>> Field("state","reference state") >>> ) >>> >>> db.define_table("address_type", >>> Field("type","string",length=100), >>> ) >>> >>> db.define_table("address", >>> Field("number","integer"), >>> Field("public_place","string"), >>> Field("cep","string",length=15), >>> Field("complement","string"), >>> Field("cities",'reference cities'), >>> Field("address_type",'reference address_type'), >>> Field("person",'reference person', writable=False,readable=False) >>> ) >>> >>> >>> >>> >>> This is my view >>> >>> >> method="post"> >>> >>> >>> >>> >> type="text" placeholder="nome"> >>> >>> >>> >>> >> type="text" placeholder="cpf"> >>> >>> >>> >>> >>> >> name="email" type="text" placeholder="email"> >>> >>> >>> >>> >>> >>> >> id="no_table_address_type" name="address_type" data-style="btn-info >>> btn-outline-info"> >>> >>> {{for t in address_type_list:}} >>> {{=t.type}} >>> {{pass}} >>> >>> >>> >>> >> data-style="btn-info btn-outline-info" required> >>> {{for city in cities_list:}} >>> {{=city.name}} >>> {{pass}} >>> >>> >>> >>> >>> >>> {{=form.hidden_fields()}} >>> >>> >>> >>> >>> >>> >> data-dismiss="modal">Cancelar >>> >>> >>> >>> >>> >>> >>> >>> now the problem: this selectpicker, simply my form can not store the >>> value of select, when I add this class, I needed it, I do not need it that >>> much, but it became a mission to understand what's happening here, I gave a >>> print em form. vars.cities and she's just like None, help please >>> >>> >> 'rodg...@gmail.com', 'registration_date' public_place ':' ',' '' '' '' >>> '' '' '' '' '' '' 'cities': None, 'address_type': None, 'person': 4}> >>> >> -- Resources: - http://web2py.com - http://web2py.com/book
[web2py] Re: custom form web2py not work when i use selectpicker
@auth.requires_login() def students(): form = form=SQLFORM.factory(db.person, db.address) cities_list = db(db.cities.id>0).select(db.cities.ALL) address_type_list = db(db.address_type.id>0).select(db.address_type.ALL) person_list = db(db.person.id>0).select(db.person.ALL) if form.process().accepted: id = db.person.insert(**db.person._filter_fields(form.vars)) form.vars.person=id id = db.address.insert(**db.address._filter_fields(form.vars)) redirect(URL('default','students')) response.flash='Form Submetido com sucesso!' elif form.errors: print(form.errors) print(form.vars) else: print('please fill out the form') return dict(form=form, cities_list=cities_list, address_type_list=address_type_list, person_list=person_list) terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang escreveu: > > How did you define your cities_list? > > On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote: >> >> >> Good evening, folks, I've come here to unveil a mystery, I'm developing >> an application with web2py, (framework that I use about 3 years ago) >> >> I am using sqlform.factory, passing 2 tables, being that I do this to >> fill in a single form, table, person and address, for better understanding >> follows my controller, >> >> >> @auth.requires_login() >> def students(): >> form = form=SQLFORM.factory(db.person, db.address) >> >> if form.process().accepted: >>id = db.person.insert(**db.person._filter_fields(form.vars)) >>form.vars.person=id >>id = db.address.insert(**db.address._filter_fields(form.vars)) >>response.flash='Form Submetido com sucesso!' >> >> elif form.errors: >>print(form.errors) >> else: >>print('please fill out the form') >> >> >> >> >> if it helps, this is my model, the tables and their relationships, >> >> db.define_table("person", >> Field("name", "string", length=50), >> Field("cpf", "string", length=11), >> Field("birthday", "date", length=11), >> Field("email","string", length=40), >> Field("registration_date","date", length=40) >> ) >> >> db.define_table("cities", >> Field("name", "string"), >> Field("state","reference state") >> ) >> >> db.define_table("address_type", >> Field("type","string",length=100), >> ) >> >> db.define_table("address", >> Field("number","integer"), >> Field("public_place","string"), >> Field("cep","string",length=15), >> Field("complement","string"), >> Field("cities",'reference cities'), >> Field("address_type",'reference address_type'), >> Field("person",'reference person', writable=False,readable=False) >> ) >> >> >> >> >> This is my view >> >> > method="post"> >> >> >> >> > type="text" placeholder="nome"> >> >> >> >> > type="text" placeholder="cpf"> >> >> >> >> >> > type="text" placeholder="email"> >> >> >> >> >> >> > id="no_table_address_type" name="address_type" data-style="btn-info >> btn-outline-info"> >> >> {{for t in address_type_list:}} >> {{=t.type}} >> {{pass}} >> >> >> >> > data-style="btn-info btn-outline-info" required> >> {{for city in cities_list:}} >> {{=city.name}} >> {{pass}} >> >> >> >> >> >> {{=form.hidden_fields()}} >> >> >> >> >> >> > data-dismiss="modal">Cancelar >> >> >> >> >> >> >> >> now the problem: this selectpicker, simply my form can not store the >> value of select, when I add this class, I needed it, I do not need it that >> much, but it became a mission to understand what's happening here, I gave a >> print em form. vars.cities and she's just like None, help please >> >> > rodg...@gmail.com', 'registration_date' public_place ':' ',' '' '' '' '' >> '' '' '' '' '' 'cities': None, 'address_type': None, 'person': 4}> >> > -- 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.
[web2py] Re: custom form web2py not work when i use selectpicker
@auth.requires_login() def students(): form = form=SQLFORM.factory(db.person, db.address) cities_list = db(db.cities.id>0).select(db.cities.ALL) address_type_list = db(db.address_type.id>0).select(db.address_type.ALL) person_list = db(db.person.id>0).select(db.person.ALL) if form.process().accepted: id = db.person.insert(**db.person._filter_fields(form.vars)) form.vars.person=id id = db.address.insert(**db.address._filter_fields(form.vars)) redirect(URL('default','students')) response.flash='Form Submetido com sucesso!' elif form.errors: print(form.errors) print(form.vars) else: print('please fill out the form') return dict(form=form, cities_list=cities_list, address_type_list= address_type_list, person_list=person_list) terça-feira, 21 de Agosto de 2018 às 10:10:39 UTC-3, Peng Wang escreveu: > > How did you define your cities_list? > > On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote: >> >> >> Good evening, folks, I've come here to unveil a mystery, I'm developing >> an application with web2py, (framework that I use about 3 years ago) >> >> I am using sqlform.factory, passing 2 tables, being that I do this to >> fill in a single form, table, person and address, for better understanding >> follows my controller, >> >> >> @auth.requires_login() >> def students(): >> form = form=SQLFORM.factory(db.person, db.address) >> >> if form.process().accepted: >>id = db.person.insert(**db.person._filter_fields(form.vars)) >>form.vars.person=id >>id = db.address.insert(**db.address._filter_fields(form.vars)) >>response.flash='Form Submetido com sucesso!' >> >> elif form.errors: >>print(form.errors) >> else: >>print('please fill out the form') >> >> >> >> >> if it helps, this is my model, the tables and their relationships, >> >> db.define_table("person", >> Field("name", "string", length=50), >> Field("cpf", "string", length=11), >> Field("birthday", "date", length=11), >> Field("email","string", length=40), >> Field("registration_date","date", length=40) >> ) >> >> db.define_table("cities", >> Field("name", "string"), >> Field("state","reference state") >> ) >> >> db.define_table("address_type", >> Field("type","string",length=100), >> ) >> >> db.define_table("address", >> Field("number","integer"), >> Field("public_place","string"), >> Field("cep","string",length=15), >> Field("complement","string"), >> Field("cities",'reference cities'), >> Field("address_type",'reference address_type'), >> Field("person",'reference person', writable=False,readable=False) >> ) >> >> >> >> >> This is my view >> >> > method="post"> >> >> >> >> > type="text" placeholder="nome"> >> >> >> >> > type="text" placeholder="cpf"> >> >> >> >> >> > type="text" placeholder="email"> >> >> >> >> >> >> > id="no_table_address_type" name="address_type" data-style="btn-info >> btn-outline-info"> >> >> {{for t in address_type_list:}} >> {{=t.type}} >> {{pass}} >> >> >> >> > data-style="btn-info btn-outline-info" required> >> {{for city in cities_list:}} >> {{=city.name}} >> {{pass}} >> >> >> >> >> >> {{=form.hidden_fields()}} >> >> >> >> >> >> > data-dismiss="modal">Cancelar >> >> >> >> >> >> >> >> now the problem: this selectpicker, simply my form can not store the >> value of select, when I add this class, I needed it, I do not need it that >> much, but it became a mission to understand what's happening here, I gave a >> print em form. vars.cities and she's just like None, help please >> >> > rodg...@gmail.com', 'registration_date' public_place ':' ',' '' '' '' '' >> '' '' '' '' '' 'cities': None, 'address_type': None, 'person': 4}> >> > -- 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] Re: custom form web2py not work when i use selectpicker
How did you define your cities_list? On Thursday, August 16, 2018 at 4:39:35 PM UTC-7, Rodrigo Gomes wrote: > > > Good evening, folks, I've come here to unveil a mystery, I'm developing an > application with web2py, (framework that I use about 3 years ago) > > I am using sqlform.factory, passing 2 tables, being that I do this to fill > in a single form, table, person and address, for better understanding > follows my controller, > > > @auth.requires_login() > def students(): > form = form=SQLFORM.factory(db.person, db.address) > > if form.process().accepted: >id = db.person.insert(**db.person._filter_fields(form.vars)) >form.vars.person=id >id = db.address.insert(**db.address._filter_fields(form.vars)) >response.flash='Form Submetido com sucesso!' > > elif form.errors: >print(form.errors) > else: >print('please fill out the form') > > > > > if it helps, this is my model, the tables and their relationships, > > db.define_table("person", > Field("name", "string", length=50), > Field("cpf", "string", length=11), > Field("birthday", "date", length=11), > Field("email","string", length=40), > Field("registration_date","date", length=40) > ) > > db.define_table("cities", > Field("name", "string"), > Field("state","reference state") > ) > > db.define_table("address_type", > Field("type","string",length=100), > ) > > db.define_table("address", > Field("number","integer"), > Field("public_place","string"), > Field("cep","string",length=15), > Field("complement","string"), > Field("cities",'reference cities'), > Field("address_type",'reference address_type'), > Field("person",'reference person', writable=False,readable=False) > ) > > > > > This is my view > > method="post"> > > > > type="text" placeholder="nome"> > > > > type="text" placeholder="cpf"> > > > > > type="text" placeholder="email"> > > > > > > id="no_table_address_type" name="address_type" data-style="btn-info > btn-outline-info"> > > {{for t in address_type_list:}} > {{=t.type}} > {{pass}} > > > > data-style="btn-info btn-outline-info" required> > {{for city in cities_list:}} > {{=city.name}} > {{pass}} > > > > > > {{=form.hidden_fields()}} > > > > > > data-dismiss="modal">Cancelar > > > > > > > > now the problem: this selectpicker, simply my form can not store the value > of select, when I add this class, I needed it, I do not need it that much, > but it became a mission to understand what's happening here, I gave a print > em form. vars.cities and she's just like None, help please > > rodg...@gmail.com ', 'registration_date' public_place ':' > ',' '' '' '' '' '' '' '' '' '' 'cities': None, 'address_type': None, > 'person': 4}> > -- 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.
[web2py] Re: custom form web2py not work when i use selectpicker
some one help me pleas quinta-feira, 16 de Agosto de 2018 às 20:39:35 UTC-3, Rodrigo Gomes escreveu: > > > Good evening, folks, I've come here to unveil a mystery, I'm developing an > application with web2py, (framework that I use about 3 years ago) > > I am using sqlform.factory, passing 2 tables, being that I do this to fill > in a single form, table, person and address, for better understanding > follows my controller, > > > @auth.requires_login() > def students(): > form = form=SQLFORM.factory(db.person, db.address) > > if form.process().accepted: >id = db.person.insert(**db.person._filter_fields(form.vars)) >form.vars.person=id >id = db.address.insert(**db.address._filter_fields(form.vars)) >response.flash='Form Submetido com sucesso!' > > elif form.errors: >print(form.errors) > else: >print('please fill out the form') > > > > > if it helps, this is my model, the tables and their relationships, > > db.define_table("person", > Field("name", "string", length=50), > Field("cpf", "string", length=11), > Field("birthday", "date", length=11), > Field("email","string", length=40), > Field("registration_date","date", length=40) > ) > > db.define_table("cities", > Field("name", "string"), > Field("state","reference state") > ) > > db.define_table("address_type", > Field("type","string",length=100), > ) > > db.define_table("address", > Field("number","integer"), > Field("public_place","string"), > Field("cep","string",length=15), > Field("complement","string"), > Field("cities",'reference cities'), > Field("address_type",'reference address_type'), > Field("person",'reference person', writable=False,readable=False) > ) > > > > > This is my view > > method="post"> > > > > type="text" placeholder="nome"> > > > > type="text" placeholder="cpf"> > > > > > type="text" placeholder="email"> > > > > > > id="no_table_address_type" name="address_type" data-style="btn-info > btn-outline-info"> > > {{for t in address_type_list:}} > {{=t.type}} > {{pass}} > > > > data-style="btn-info btn-outline-info" required> > {{for city in cities_list:}} > {{=city.name}} > {{pass}} > > > > > > {{=form.hidden_fields()}} > > > > > > data-dismiss="modal">Cancelar > > > > > > > > now the problem: this selectpicker, simply my form can not store the value > of select, when I add this class, I needed it, I do not need it that much, > but it became a mission to understand what's happening here, I gave a print > em form. vars.cities and she's just like None, help please > > rodgom...@gmail.com', 'registration_date' public_place ':' ',' '' '' '' > '' '' '' '' '' '' 'cities': None, 'address_type': None, 'person': 4}> > -- 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.
[web2py] Re: Custom form with select boxes set selected from a variable in a loop
The problem is that you are passing the same OPTION objects to SELECT each time, and when you set the "value" attribute of SELECT, it *mutates* the OPTION objects. So, the final pass through the loop sets the OPTION objects, which appear in each of the SELECT objects. Instead, you should create new OPTION objects for each SELECT. Also, there is no reason to create a "shifts" dictionary -- just iterate over a list: for row in ['1', '2', '3']: Also, keep in mind that unless you are using Python 3.7, there is no guarantee regarding the order of iteration over dictionary keys. Anthony On Wednesday, June 6, 2018 at 10:01:47 AM UTC-4, Ischa Guns wrote: > > Hello, > > I am trying to make a custom form with select boxes. I am using the SELECT > helper to create the select boxes. I have a problem with setting the > selected value. I have created the following example. > > def test_select(): > users = [('0', 'None'), > ('1', 'John'), > ('3', 'Someone Else'), > ('2', 'Jane') > ] > resources = [OPTION(x[1], _value=x[0]) for x in users] > shifts = {1:'1',2:'2',3:'3'} > tab = TABLE() > trow = TR() > for row in shifts: > trow.append(TD(SELECT(*resources, > _name='name', > _id='name', > value=shifts[row], > _style="background-color:%s;" % 'yellow') > ) >) > tab.append(trow) > form = FORM(tab) > return dict(form=form) > > I am trying to set the value by looping through the "shifts" dictionary > and assigning the "value" to the value from the dictionary. I expected that > the first dropdown would be set to "John", the second to "Jane" and the 3rd > to "Someone Else", but this is not happening. All 3 the dropdown lists are > set to "Someone Else". > > How can I assign the value of the select box properly? > -- 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.
[web2py] Re: custom form submit not working - form.accepts not triggered
The grid code already calls the .process() method (which calls .accepts()) -- you cannot call .accepts() a second time. If you want a custom form, you need to completely replace the form generated by the grid. But in this case, there should be no need for that -- just use the grid's onvalidation, oncreate, onupdate, onedit, and ondelete callbacks, which will be passed to .process() within the grid code. Anthony On Tuesday, November 7, 2017 at 7:32:48 AM UTC-5, Yebach wrote: > > Hello > > I am trying to implement a custom form for SQLFORM.grid > > When submit is clicked the data is not inserted. I think the problem is > when I validate form and the form.accepts is not triggered. > > this is my controler > > def workers(): > #some code before but not relevant > > grid_workers = SQLFORM.grid(query=query, > left=db.status.on(db.workers.w_status == db.status.id), > fields=fields, searchable=False, > orderby=[db.workers.w_nick_name], create=True, > deletable=False, editable=True, paginate=100, > buttons_placement='right', > showbuttontext=False, > links=links, > ui=dict(widget='', > header='', > content='', > default='', > cornerall='', > cornertop='', > cornerbottom='', > button='button btn btn-default', > buttontext='buttontext button', > buttonadd='icon plus icon-plus glyphicon > glyphicon-plus', > buttonback='icon leftarrow > icon-arrow-left glyphicon glyphicon-arrow-left', > buttonexport='icon downarrow > icon-download glyphicon glyphicon-download', > buttondelete='icon trash icon-trash > glyphicon glyphicon-trash', > buttonedit='icon pen icon-pencil > glyphicon glyphicon-pencil', > buttontable='icon rightarrow > icon-arrow-right glyphicon glyphicon-arrow-right', > buttonview='icon magnifier icon-zoom-in > glyphicon glyphicon-eye-open', > ), > exportclasses=dict(csv=False, csv_with_hidden_cols=False, >html=False, > tsv_with_hidden_cols=False,json=False, tsv= False, xml = False)) > > > def my_form_processing_new(form): > print "tukej111" > nick_name = form.vars.w_nick_name > workers = db((db.workers.w_organization == org) & (db.workers.w_nick_name > == nick_name) & (db.workers.w_status != 250)).select() > partner_id = form.vars.partner_id > if workers: > form.errors.w_nick_name = T('Worker with this nick name already > exists!') > if not partner_id or partner_id == '': > form.vars.partner_id = -1 > > > def my_form_processing_edit(form): > > #some code not relevant ATM > >if (request.args) and (request.args[0] in ['new']): > print "juhu" > form = grid_workers.create_form > #grid_workers.element('[title=Back]').parent['_href'] = URL('settings', > 'workers') > if form.accepts(request.vars, session, > onvalidation=my_form_processing_new): > print "tukej" > session.flash = T('Worker inserted') > redirect(URL()) > return dict(form = form, inactive_workers=query_inactive) > > if (request.args) and (request.args[0] in ['edit']): > form = grid_workers.update_form > #grid_workers.element('[title=Back]').parent['_href'] = URL('settings', > 'workers') > if form.accepts(request.vars, session, onvalidation = > my_form_processing_edit): > my_form_processing_edit(form) > session.flash = T('Worker updated') > redirect(URL()) > return dict(form = form, inactive_workers=query_inactive) > > > return dict(grid_workers = grid_workers, inactive_workers=query_inactive) > > > and my view > > > > {{if ('new' in request.args) or ('edit' in request.args):}} >{{=form.custom.begin}} >Status: {{=form.custom.widget.w_status}} >First name: {{=form.custom.widget.w_first_name}} >Last name: {{=form.custom.widget.w_last_name}} >Nick name: {{=form.custom.widget.w_nick_name}} >E-mail: {{=form.custom.widget.w_email}} >Work type: {{=form.custom.widget.w_work_type}} >Month hour formula: {{=form.custom.widget.w_hour_formula}} >Work obligation (minutes): > {{=form.custom.widget.w_day_obligation}} >Partner ID : {{=form.custom.widget.partner_id}} >Comment: {{=form.custom.widget.w_note}} >{{=form.custom.submit}} >{{=form.custom.end}} > {{else:}} >{{=grid_workers}} > {{pass}} > > > > > So the if form.accepts(request.vars,
[web2py] Re: Custom form errors?
> I tried putting the functions you mentioned in the process and validate > method in the "user" function, but still no luck. > If you're talking about the default user() function, then you should have something like form=auth(), in which case, you cannot use the .process() or .validate() method, as auth() already handles that. If you want to add callbacks to the auth() form processing, you must do so via the various auth.settings options. In any case, though, you can still access the errors as usual, as auth() returns a processed SQLFORM object: form = auth() errors = form.errors Anthony -- 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.
[web2py] Re: Custom form errors?
On Tuesday, March 7, 2017 at 1:34:31 AM UTC-5, LoveWeb2py wrote: > > If I'm reading this correctly: > http://web2py.com/books/default/chapter/29/07/forms-and-validators#Hide-errors > I was just pointing that out to show how to access the errors -- you can certainly do so in the controller. Anthony -- 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.
[web2py] Re: Custom form errors?
On Monday, March 6, 2017 at 10:34:31 PM UTC-8, LoveWeb2py wrote: > > If I'm reading this correctly: > http://web2py.com/books/default/chapter/29/07/forms-and-validators#Hide-errors > > It looks like everything is now handled in the view and NOT the > controller, so I'd need to do all of my checks in the view. Does that sound > right? > > The accept() is still in the controller. The display of errors can be moved to the view. /dps > On Tuesday, March 7, 2017 at 1:31:32 AM UTC-5, LoveWeb2py wrote: >> >> Thank you, Anthony, but I'm using a custom form via the "user" >> controller. >> >> Here is my code >> >> {{=form.custom.begin}} >> >> >> >> >> {{form.custom.widget.username.update(_placeholder="Username")}} >>{{=form.custom.widget.username}} >> >> >> >> >> >> >> >> {{form.custom.widget.password.update(_placeholder="Password")}} >>{{=form.custom.widget.password}} >> >> >> >> >> >> >> >> Remember me >> >> >> >> >> Forgot >> password? >> >> >> >> >> >> >>{{=form.custom.submit}} >> >> >> >> >> >> Or >> >> >> >> Facebook Sign in >> >> >> >> >> Twitter Sign in >> >> >> >> Don't have an account? > href="{{=URL('default','register')}}">Create New >> >> >>{{=form.custom.end}} >> >> >> I tried putting the functions you mentioned in the process and validate >> method in the "user" function, but still no luck. >> >> On Tuesday, March 7, 2017 at 12:39:18 AM UTC-5, Anthony wrote: >>> >>> See >>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#The-process-and-validate-methods >>> >>> and >>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Hide-errors >>> . >>> >>> After processing, errors are stored in form.errors (to get the error for >>> a given field, use form.errors[fieldname]). >>> >>> Anthony >>> >>> On Tuesday, March 7, 2017 at 12:06:45 AM UTC-5, LoveWeb2py wrote: Hello, I have some custom login forms and I'm something like this: {{=form.custom.begin}}Image name: {{=form.custom.widget.name}}Image file: {{=form.custom.widget.file}}Click here to upload: {{=form.custom.submit}}{{=form.custom.end}} How can I check for errors here? I'm lost at where form gets checked. For example, if the user types an invalid password or username, I'd like to generate a custom message with response.flash or something to that nature. -- 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.
[web2py] Re: Custom form errors?
If I'm reading this correctly: http://web2py.com/books/default/chapter/29/07/forms-and-validators#Hide-errors It looks like everything is now handled in the view and NOT the controller, so I'd need to do all of my checks in the view. Does that sound right? On Tuesday, March 7, 2017 at 1:31:32 AM UTC-5, LoveWeb2py wrote: > > Thank you, Anthony, but I'm using a custom form via the "user" controller. > > Here is my code > > {{=form.custom.begin}} > > > > > {{form.custom.widget.username.update(_placeholder="Username")}} >{{=form.custom.widget.username}} > > > > > > > > {{form.custom.widget.password.update(_placeholder="Password")}} >{{=form.custom.widget.password}} > > > > > > > > Remember me > > > > > Forgot > password? > > > > > > >{{=form.custom.submit}} > > > > > > Or > > > > Facebook Sign in > > > > > Twitter Sign in > > > > Don't have an account? href="{{=URL('default','register')}}">Create New > > >{{=form.custom.end}} > > > I tried putting the functions you mentioned in the process and validate > method in the "user" function, but still no luck. > > On Tuesday, March 7, 2017 at 12:39:18 AM UTC-5, Anthony wrote: >> >> See >> http://web2py.com/books/default/chapter/29/07/forms-and-validators#The-process-and-validate-methods >> >> and >> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Hide-errors >> . >> >> After processing, errors are stored in form.errors (to get the error for >> a given field, use form.errors[fieldname]). >> >> Anthony >> >> On Tuesday, March 7, 2017 at 12:06:45 AM UTC-5, LoveWeb2py wrote: >>> >>> Hello, >>> >>> I have some custom login forms and I'm something like this: >>> >>> >>> {{=form.custom.begin}}Image name: >>> {{=form.custom.widget.name}}Image file: >>> {{=form.custom.widget.file}}Click here to upload: >>> {{=form.custom.submit}}{{=form.custom.end}} >>> >>> How can I check for errors here? >>> >>> I'm lost at where form gets checked. For example, if the user types an >>> invalid password or username, I'd like to generate a custom message with >>> response.flash or something to that nature. >>> >>> -- 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.
[web2py] Re: Custom form errors?
Thank you, Anthony, but I'm using a custom form via the "user" controller. Here is my code {{=form.custom.begin}} {{form.custom.widget.username.update(_placeholder="Username")}} {{=form.custom.widget.username}} {{form.custom.widget.password.update(_placeholder="Password")}} {{=form.custom.widget.password}} Remember me Forgot password? {{=form.custom.submit}} Or Facebook Sign in Twitter Sign in Don't have an account? Create New {{=form.custom.end}} I tried putting the functions you mentioned in the process and validate method in the "user" function, but still no luck. On Tuesday, March 7, 2017 at 12:39:18 AM UTC-5, Anthony wrote: > > See > http://web2py.com/books/default/chapter/29/07/forms-and-validators#The-process-and-validate-methods > > and > http://web2py.com/books/default/chapter/29/07/forms-and-validators#Hide-errors > . > > After processing, errors are stored in form.errors (to get the error for a > given field, use form.errors[fieldname]). > > Anthony > > On Tuesday, March 7, 2017 at 12:06:45 AM UTC-5, LoveWeb2py wrote: >> >> Hello, >> >> I have some custom login forms and I'm something like this: >> >> >> {{=form.custom.begin}}Image name: >> {{=form.custom.widget.name}}Image file: >> {{=form.custom.widget.file}}Click here to upload: >> {{=form.custom.submit}}{{=form.custom.end}} >> >> How can I check for errors here? >> >> I'm lost at where form gets checked. For example, if the user types an >> invalid password or username, I'd like to generate a custom message with >> response.flash or something to that nature. >> >> -- 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.
[web2py] Re: Custom form errors?
See http://web2py.com/books/default/chapter/29/07/forms-and-validators#The-process-and-validate-methods and http://web2py.com/books/default/chapter/29/07/forms-and-validators#Hide-errors. After processing, errors are stored in form.errors (to get the error for a given field, use form.errors[fieldname]). Anthony On Tuesday, March 7, 2017 at 12:06:45 AM UTC-5, LoveWeb2py wrote: > > Hello, > > I have some custom login forms and I'm something like this: > > > {{=form.custom.begin}}Image name: > {{=form.custom.widget.name}}Image file: > {{=form.custom.widget.file}}Click here to upload: > {{=form.custom.submit}}{{=form.custom.end}} > > How can I check for errors here? > > I'm lost at where form gets checked. For example, if the user types an > invalid password or username, I'd like to generate a custom message with > response.flash or something to that nature. > > -- 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.
Re: [web2py] Re: custom form default value
Thank you, I was completely unaware that this syntax was needed. I will never get those 2 hrs of my life back, but thanks to you I will sleep well tonight!!! You are THE BOSS. On Wed, Dec 21, 2016 at 5:52 AM, Anthonywrote: > > id="sample_sample_name" class="text" value={{=row.sample_name}}/> >> > > It's always a good idea to check the returned HTML source in the browser. > In this case, you will see you forgot the quotes around the value -- should > be: > > value="{{=row.sample_name}}" > > You're getting: > > value=RED CAR WITH ROOF > > instead of: > > value="RED CAR WITH ROOF" > > Anthony > > -- > 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 a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/web2py/IZ0fe7WxYYg/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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.
[web2py] Re: custom form default value
> > id="sample_sample_name" class="text" value={{=row.sample_name}}/> > It's always a good idea to check the returned HTML source in the browser. In this case, you will see you forgot the quotes around the value -- should be: value="{{=row.sample_name}}" You're getting: value=RED CAR WITH ROOF instead of: value="RED CAR WITH ROOF" Anthony -- 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.
[web2py] Re: custom form validation doesn't work
That doesn't necessarily sound like the same issue. Please show some code and explain what you expect and what you see instead (maybe start a new thread). On Sunday, May 10, 2015 at 10:01:54 AM UTC-4, Thomas Sitter wrote: Hi Massimo, I am getting this same issue (onvalidation function not getting called), but I am use SQLFORM and not Crud so the solution posted does not apply to me. Has this been resolved elsewhere? Thanks. Tom On Saturday, 15 December 2012 18:27:51 UTC-5, jonas wrote: Hi. I have a default form that is passed in view: {{=form}} using this validation and insertion works. but when I use a custom form none of that works. why? Also form.process().accepted works only when using default form. My second question is: when submitting the form I redirect to index, and all entries in the db are returned. Is that because i reuse the index function? Is there any way to clear all fields after a successful submit? the code: default.py: def index(): query=db.blog.id0 res=db(query).select(orderby=~db.blog.date) query=db.about.id0 about=db(query).select() query=db.comments.post_id0 com=db(query).select(orderby=~db.comments.created_on) return dict(res=res,about=about,com=com,message=T('Everything should be made as simple as possible, but not simpler')) def comment(): create comment form. Every comment is id locked to the specific post post=db(db.blog.id==request.args(0)).select().first() db.comments.post_id.default=post.id form=crud.create(db.comments) if form.process().accepted: print 'form accepted' redirect(URL('index')) else: print 'not accepted' return dict(form=form) index.html: {{=A(TAG.i(_class=icon-plus-sign), _rel=tooltip, _title=testing, _class=btn, _href='#', _onclick=jQuery('#uc').toggle();)}} div id=uc {{=LOAD('default','comment.load',args=result.id,ajax=True)}} /div comment.load: {{=form}} thanks -- 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.
[web2py] Re: custom form validation doesn't work
Hi Massimo, I am getting this same issue (onvalidation function not getting called), but I am use SQLFORM and not Crud so the solution posted does not apply to me. Has this been resolved elsewhere? Thanks. Tom On Saturday, 15 December 2012 18:27:51 UTC-5, jonas wrote: Hi. I have a default form that is passed in view: {{=form}} using this validation and insertion works. but when I use a custom form none of that works. why? Also form.process().accepted works only when using default form. My second question is: when submitting the form I redirect to index, and all entries in the db are returned. Is that because i reuse the index function? Is there any way to clear all fields after a successful submit? the code: default.py: def index(): query=db.blog.id0 res=db(query).select(orderby=~db.blog.date) query=db.about.id0 about=db(query).select() query=db.comments.post_id0 com=db(query).select(orderby=~db.comments.created_on) return dict(res=res,about=about,com=com,message=T('Everything should be made as simple as possible, but not simpler')) def comment(): create comment form. Every comment is id locked to the specific post post=db(db.blog.id==request.args(0)).select().first() db.comments.post_id.default=post.id form=crud.create(db.comments) if form.process().accepted: print 'form accepted' redirect(URL('index')) else: print 'not accepted' return dict(form=form) index.html: {{=A(TAG.i(_class=icon-plus-sign), _rel=tooltip, _title=testing, _class=btn, _href='#', _onclick=jQuery('#uc').toggle();)}} div id=uc {{=LOAD('default','comment.load',args=result.id,ajax=True)}} /div comment.load: {{=form}} thanks -- 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.
[web2py] Re: Custom Form Widget Question
Great idea. I did that and it works perfectly! On Monday, May 5, 2014 4:00:59 PM UTC-4, Jim S wrote: Maybe a dropdown isn't the right control for this situation. Have you considered an autocomplete widget? How many rows are in your dropdown? -Jim On Saturday, May 3, 2014 3:13:40 PM UTC-5, Mark Billion wrote: How can I set the width of the dropdown menu for an input? The thing is way too long because its trying to be longer than the textsorry, I know its dumb, but I cant find anything -- 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.
[web2py] Re: Custom Form Widget Question
Maybe a dropdown isn't the right control for this situation. Have you considered an autocomplete widget? How many rows are in your dropdown? -Jim On Saturday, May 3, 2014 3:13:40 PM UTC-5, Mark Billion wrote: How can I set the width of the dropdown menu for an input? The thing is way too long because its trying to be longer than the textsorry, I know its dumb, but I cant find anything -- 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.
[web2py] Re: Custom form with jquery acts weird
Hi Anthony, Thanks for your note. Like I said, I understand the helpful comments on fixing the button onclick... issue. However, what is unclear to me still is Massimo's (and yours here - https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ ) comments on form processing.. Massimo pointed out that, a la Jonas' post, that you cannot do - form=crud.create(db.comments) if form.process().accepted ...yet I have: form = SQLFORM.factory(*fields) if form.accepts(request, session): ...and that also seems to be wrong (no doubt, since process() is a shortcut for accepts(), they are doing the same thing). BUT I am not sure how to correct it - you both said that process is getting called twice. OK, if I shouldn't use 'if form.accepts(request, session): ' then what should I use to process (and call validation on) the form once the user clicks 'Submit' ? Thanks again, -jl On Friday, September 27, 2013 7:36:04 PM UTC-7, Anthony wrote: If you follow Massimo's suggestion: button onclick=event.preventDefault();window.location='{{=URL('index ')}}'Cancel/button everything seems to work fine. What problem do you have after making that change? Anthony On Friday, September 27, 2013 9:00:47 PM UTC-4, Jordan Ladora wrote: Hi Massimo, Thanks for your help. I think I'm crystal clear on your explanation regarding the button, but I'm still confused on the other issue that Anthony answered previously, despite his and your posts.. In my controller I used: form = SQLFORM.factory(*fields) if form.accepts(request, session): Could you please be a little more specific? What should I use here instead of 'form.accepts' ? I think this is causing me trouble elsewhere in my application, too, and it would be really helpful if I knew a little bit more.. Thanks again, -J On Tuesday, September 17, 2013 12:15:01 PM UTC-7, Jordan Ladora wrote: Hi, I have the same problem as https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/E9RyEqh01RQ/6duW4RmALvcJ From the first thread/link above, ...if I use a regular form, {{=form}}, then validation works but not if I use the custom form. Also form.process() works, so the problem seems to be related to custom forms.. Those threads seemed to end without finding a solution. I think the author of those threads didn't realize that the form is actually being validated, but it doesn't seem like it b/c the error messages do not show with the custom form. In my hands, if I use a custom form, it validates OK but form errors do not display and, quite often, any jquery code in the view misbehaves (which is the real problem). This behavior turns on and off depending ONLY on whether I have a custom form. I used {{=custom.form.begin}} and {{=custom.form.end}} and {{=form.custom.widget.xyz}} and {{=form.custom.label.xyz}} in the view. If I replace it with {{=form}} then everything works perfectly. In the controller, I used if form.accepts(request, session, onvalidation=abc): ... Thanks for any help. I love the custom forms and it really stinks not being able to use them with jQuery!! -jl ps - I previously posted with more details about this problem, before I realized the problem seems related more generally to javascript/jquery + custom forms - https://groups.google.com/forum/?fromgroups=#!topic/web2py/rPHKPqqHbsg https://groups.google.com/forum/?fromgroups=#!topic/web2py/0LpfMJPwSsI -- 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/groups/opt_out.
[web2py] Re: Custom form with jquery acts weird
form=crud.create(db.comments) if form.process().accepted Right, you cannot do that. form = SQLFORM.factory(*fields) if form.accepts(request, session): The above is perfectly fine (though form.process().accepted is now preferred to form.accepts(request, session)). My question was exactly what problem are you having with the aboveThe app you attached uses the above, and it works fine. Anthony -- 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/groups/opt_out.
[web2py] Re: Custom form with jquery acts weird
Thanks for that - I'd assumed the button in the form was related, but let me try and isolate the other problem and make another app that reproduces it. On Saturday, September 28, 2013 10:09:58 AM UTC-7, Anthony wrote: form=crud.create(db.comments) if form.process().accepted Right, you cannot do that. form = SQLFORM.factory(*fields) if form.accepts(request, session): The above is perfectly fine (though form.process().accepted is now preferred to form.accepts(request, session)). My question was exactly what problem are you having with the above? The app you attached uses the above, and it works fine. Anthony -- 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/groups/opt_out.
[web2py] Re: custom form validation doesn't work
The problems was identified by Anthony in this thread: https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ On Saturday, 15 December 2012 17:27:51 UTC-6, jonas wrote: Hi. I have a default form that is passed in view: {{=form}} using this validation and insertion works. but when I use a custom form none of that works. why? Also form.process().accepted works only when using default form. My second question is: when submitting the form I redirect to index, and all entries in the db are returned. Is that because i reuse the index function? Is there any way to clear all fields after a successful submit? the code: default.py: def index(): query=db.blog.id0 res=db(query).select(orderby=~db.blog.date) query=db.about.id0 about=db(query).select() query=db.comments.post_id0 com=db(query).select(orderby=~db.comments.created_on) return dict(res=res,about=about,com=com,message=T('Everything should be made as simple as possible, but not simpler')) def comment(): create comment form. Every comment is id locked to the specific post post=db(db.blog.id==request.args(0)).select().first() db.comments.post_id.default=post.id form=crud.create(db.comments) if form.process().accepted: print 'form accepted' redirect(URL('index')) else: print 'not accepted' return dict(form=form) index.html: {{=A(TAG.i(_class=icon-plus-sign), _rel=tooltip, _title=testing, _class=btn, _href='#', _onclick=jQuery('#uc').toggle();)}} div id=uc {{=LOAD('default','comment.load',args=result.id,ajax=True)}} /div comment.load: {{=form}} thanks -- 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/groups/opt_out.
Re: [web2py] Re: Custom form with jquery acts weird
Actually the problem you have is different. The links you refer to both had the same problem and it was addressed by Anthony in his post. You cannot do: form=crud.create(db.comments) if form.process().accepted because crud.create already calls process() internally, you it was called twice. You problem is different. You have a button inside a form and if you click it, it will submit the form. Unless you tell it not to: button onclick=event.preventDefault();window.location='{{=URL('index')}}'Cancel/button On Thursday, 26 September 2013 14:44:49 UTC-5, Jordan Ladora wrote: Hello again, I've attached an app with the problem I have.. if you click on the button and go to 'debug_js' view, you'll see that hitting the 'cancel' button there causes a POST request, form reload, and validation. This is par for the problems I've been having with custom forms.. if you move that button outside the custom form, everything behaves normally.. Thanks again for help with this! -jl On Fri, Sep 20, 2013 at 2:39 PM, Marin Pranjić marin@gmail.comjavascript: wrote: Can you pack a minimal application that reproduces this? On Fri, Sep 20, 2013 at 11:18 PM, Jordan Ladora vicepres...@gmail.comjavascript: wrote: Ahhh f*ck it, then... On Tuesday, September 17, 2013 12:15:01 PM UTC-7, Jordan Ladora wrote: Hi, I have the same problem as https://groups.google.com/**forum/?fromgroups#!searchin/** web2py/custom$20form$20jquery/**web2py/7Meea7Ul0o8/**4ZdrD9hP5MEJhttps://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ https://groups.google.com/**forum/?fromgroups#!searchin/** web2py/custom$20form$20jquery/**web2py/E9RyEqh01RQ/**6duW4RmALvcJhttps://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/E9RyEqh01RQ/6duW4RmALvcJ From the first thread/link above, ...if I use a regular form, {{=form}}, then validation works but not if I use the custom form. Also form.process() works, so the problem seems to be related to custom forms.. Those threads seemed to end without finding a solution. I think the author of those threads didn't realize that the form is actually being validated, but it doesn't seem like it b/c the error messages do not show with the custom form. In my hands, if I use a custom form, it validates OK but form errors do not display and, quite often, any jquery code in the view misbehaves (which is the real problem). This behavior turns on and off depending ONLY on whether I have a custom form. I used {{=custom.form.begin}} and {{=custom.form.end}} and {{=form.custom.widget.xyz}} and {{=form.custom.label.xyz}} in the view. If I replace it with {{=form}} then everything works perfectly. In the controller, I used if form.accepts(request, session, onvalidation=abc): ... Thanks for any help. I love the custom forms and it really stinks not being able to use them with jQuery!! -jl ps - I previously posted with more details about this problem, before I realized the problem seems related more generally to javascript/jquery + custom forms - https://groups.google.com/**forum/?fromgroups=#!topic/** web2py/rPHKPqqHbsghttps://groups.google.com/forum/?fromgroups=#!topic/web2py/rPHKPqqHbsg https://groups.google.com/**forum/?fromgroups=#!topic/** web2py/0LpfMJPwSsIhttps://groups.google.com/forum/?fromgroups=#!topic/web2py/0LpfMJPwSsI -- 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+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- 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 a topic in the Google Groups web2py-users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/rHwdHamBjHI/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- 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
[web2py] Re: Custom form with jquery acts weird
Hi Massimo, Thanks for your help. I think I'm crystal clear on your explanation regarding the button, but I'm still confused on the other issue that Anthony answered previously, despite his and your posts.. In my controller I used: form = SQLFORM.factory(*fields) if form.accepts(request, session): Could you please be a little more specific? What should I use here instead of 'form.accepts' ? I think this is causing me trouble elsewhere in my application, too, and it would be really helpful if I knew a little bit more.. Thanks again, -J On Tuesday, September 17, 2013 12:15:01 PM UTC-7, Jordan Ladora wrote: Hi, I have the same problem as https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/E9RyEqh01RQ/6duW4RmALvcJ From the first thread/link above, ...if I use a regular form, {{=form}}, then validation works but not if I use the custom form. Also form.process() works, so the problem seems to be related to custom forms.. Those threads seemed to end without finding a solution. I think the author of those threads didn't realize that the form is actually being validated, but it doesn't seem like it b/c the error messages do not show with the custom form. In my hands, if I use a custom form, it validates OK but form errors do not display and, quite often, any jquery code in the view misbehaves (which is the real problem). This behavior turns on and off depending ONLY on whether I have a custom form. I used {{=custom.form.begin}} and {{=custom.form.end}} and {{=form.custom.widget.xyz}} and {{=form.custom.label.xyz}} in the view. If I replace it with {{=form}} then everything works perfectly. In the controller, I used if form.accepts(request, session, onvalidation=abc): ... Thanks for any help. I love the custom forms and it really stinks not being able to use them with jQuery!! -jl ps - I previously posted with more details about this problem, before I realized the problem seems related more generally to javascript/jquery + custom forms - https://groups.google.com/forum/?fromgroups=#!topic/web2py/rPHKPqqHbsg https://groups.google.com/forum/?fromgroups=#!topic/web2py/0LpfMJPwSsI -- 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/groups/opt_out.
[web2py] Re: Custom form with jquery acts weird
If you follow Massimo's suggestion: button onclick=event.preventDefault();window.location='{{=URL('index')}}' Cancel/button everything seems to work fine. What problem do you have after making that change? Anthony On Friday, September 27, 2013 9:00:47 PM UTC-4, Jordan Ladora wrote: Hi Massimo, Thanks for your help. I think I'm crystal clear on your explanation regarding the button, but I'm still confused on the other issue that Anthony answered previously, despite his and your posts.. In my controller I used: form = SQLFORM.factory(*fields) if form.accepts(request, session): Could you please be a little more specific? What should I use here instead of 'form.accepts' ? I think this is causing me trouble elsewhere in my application, too, and it would be really helpful if I knew a little bit more.. Thanks again, -J On Tuesday, September 17, 2013 12:15:01 PM UTC-7, Jordan Ladora wrote: Hi, I have the same problem as https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/E9RyEqh01RQ/6duW4RmALvcJ From the first thread/link above, ...if I use a regular form, {{=form}}, then validation works but not if I use the custom form. Also form.process() works, so the problem seems to be related to custom forms.. Those threads seemed to end without finding a solution. I think the author of those threads didn't realize that the form is actually being validated, but it doesn't seem like it b/c the error messages do not show with the custom form. In my hands, if I use a custom form, it validates OK but form errors do not display and, quite often, any jquery code in the view misbehaves (which is the real problem). This behavior turns on and off depending ONLY on whether I have a custom form. I used {{=custom.form.begin}} and {{=custom.form.end}} and {{=form.custom.widget.xyz}} and {{=form.custom.label.xyz}} in the view. If I replace it with {{=form}} then everything works perfectly. In the controller, I used if form.accepts(request, session, onvalidation=abc): ... Thanks for any help. I love the custom forms and it really stinks not being able to use them with jQuery!! -jl ps - I previously posted with more details about this problem, before I realized the problem seems related more generally to javascript/jquery + custom forms - https://groups.google.com/forum/?fromgroups=#!topic/web2py/rPHKPqqHbsg https://groups.google.com/forum/?fromgroups=#!topic/web2py/0LpfMJPwSsI -- 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/groups/opt_out.
Re: [web2py] Re: Custom form with jquery acts weird
Can you pack a minimal application that reproduces this? On Fri, Sep 20, 2013 at 11:18 PM, Jordan Ladora vicepresjoebi...@gmail.comwrote: Ahhh f*ck it, then... On Tuesday, September 17, 2013 12:15:01 PM UTC-7, Jordan Ladora wrote: Hi, I have the same problem as https://groups.google.com/**forum/?fromgroups#!searchin/** web2py/custom$20form$20jquery/**web2py/7Meea7Ul0o8/**4ZdrD9hP5MEJhttps://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ https://groups.google.com/**forum/?fromgroups#!searchin/** web2py/custom$20form$20jquery/**web2py/E9RyEqh01RQ/**6duW4RmALvcJhttps://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/E9RyEqh01RQ/6duW4RmALvcJ From the first thread/link above, ...if I use a regular form, {{=form}}, then validation works but not if I use the custom form. Also form.process() works, so the problem seems to be related to custom forms.. Those threads seemed to end without finding a solution. I think the author of those threads didn't realize that the form is actually being validated, but it doesn't seem like it b/c the error messages do not show with the custom form. In my hands, if I use a custom form, it validates OK but form errors do not display and, quite often, any jquery code in the view misbehaves (which is the real problem). This behavior turns on and off depending ONLY on whether I have a custom form. I used {{=custom.form.begin}} and {{=custom.form.end}} and {{=form.custom.widget.xyz}} and {{=form.custom.label.xyz}} in the view. If I replace it with {{=form}} then everything works perfectly. In the controller, I used if form.accepts(request, session, onvalidation=abc): ... Thanks for any help. I love the custom forms and it really stinks not being able to use them with jQuery!! -jl ps - I previously posted with more details about this problem, before I realized the problem seems related more generally to javascript/jquery + custom forms - https://groups.google.com/**forum/?fromgroups=#!topic/** web2py/rPHKPqqHbsghttps://groups.google.com/forum/?fromgroups=#!topic/web2py/rPHKPqqHbsg https://groups.google.com/**forum/?fromgroups=#!topic/** web2py/0LpfMJPwSsIhttps://groups.google.com/forum/?fromgroups=#!topic/web2py/0LpfMJPwSsI -- 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/groups/opt_out. -- 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/groups/opt_out.
[web2py] Re: Custom form with jquery acts weird
Ahhh f*ck it, then... On Tuesday, September 17, 2013 12:15:01 PM UTC-7, Jordan Ladora wrote: Hi, I have the same problem as https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/7Meea7Ul0o8/4ZdrD9hP5MEJ https://groups.google.com/forum/?fromgroups#!searchin/web2py/custom$20form$20jquery/web2py/E9RyEqh01RQ/6duW4RmALvcJ From the first thread/link above, ...if I use a regular form, {{=form}}, then validation works but not if I use the custom form. Also form.process() works, so the problem seems to be related to custom forms.. Those threads seemed to end without finding a solution. I think the author of those threads didn't realize that the form is actually being validated, but it doesn't seem like it b/c the error messages do not show with the custom form. In my hands, if I use a custom form, it validates OK but form errors do not display and, quite often, any jquery code in the view misbehaves (which is the real problem). This behavior turns on and off depending ONLY on whether I have a custom form. I used {{=custom.form.begin}} and {{=custom.form.end}} and {{=form.custom.widget.xyz}} and {{=form.custom.label.xyz}} in the view. If I replace it with {{=form}} then everything works perfectly. In the controller, I used if form.accepts(request, session, onvalidation=abc): ... Thanks for any help. I love the custom forms and it really stinks not being able to use them with jQuery!! -jl ps - I previously posted with more details about this problem, before I realized the problem seems related more generally to javascript/jquery + custom forms - https://groups.google.com/forum/?fromgroups=#!topic/web2py/rPHKPqqHbsg https://groups.google.com/forum/?fromgroups=#!topic/web2py/0LpfMJPwSsI -- 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/groups/opt_out.
[web2py] Re: Custom form does not show the extra field of a SQLFORM
why don't you just use the recommended way for hidden fields ? http://web2py.com/books/default/chapter/29/07#Hidden-fields On Wednesday, February 13, 2013 5:33:43 PM UTC+1, Tito Garrido wrote: Hi Folks, I am trying to add a hidden field on a SQLFORM like this: *form=SQLFORM(db.produto) tags = TR(INPUT(_name='tags_hidden',value=True,_type='hidden')) form[0].insert(-1,tags)* {{=form.custom.widget}} it does not show this extra field: Storage {'estoque_min': gluon.html.INPUT object at 0x32216d0, 'preco_custo': gluon.html.INPUT object at 0x3221410, 'tipo': gluon.html.SELECT object at 0x3221150, 'tags': gluon.html.SELECT object at 0x3221dd0, 'preco_venda': gluon.html.INPUT object at 0x3221310, 'observacao': gluon.html.TEXTAREA object at 0x3221d50, 'estoque_max': gluon.html.INPUT object at 0x32217d0, 'fornecedor': gluon.html.SELECT object at 0x3221b10, 'unidade': gluon.html.INPUT object at 0x3221510, 'codigo': gluon.html.INPUT object at 0x32210d0, 'ativo': gluon.html.INPUT object at 0x32215d0, 'id': '', 'descricao': gluon.html.INPUT object at 0x31f3fd0} Is it expected? Regards, Tito -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- --- 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.
[web2py] Re: Custom form does not show the extra field of a SQLFORM
No, it is not expected. The form.custom.widget items are created when the form is created. You have added the extra field after form creation. The .insert() method only inserts into the FORM object's DOM -- it does not update form.custom.widget. Anthony On Wednesday, February 13, 2013 11:33:43 AM UTC-5, Tito Garrido wrote: Hi Folks, I am trying to add a hidden field on a SQLFORM like this: *form=SQLFORM(db.produto) tags = TR(INPUT(_name='tags_hidden',value=True,_type='hidden')) form[0].insert(-1,tags)* {{=form.custom.widget}} it does not show this extra field: Storage {'estoque_min': gluon.html.INPUT object at 0x32216d0, 'preco_custo': gluon.html.INPUT object at 0x3221410, 'tipo': gluon.html.SELECT object at 0x3221150, 'tags': gluon.html.SELECT object at 0x3221dd0, 'preco_venda': gluon.html.INPUT object at 0x3221310, 'observacao': gluon.html.TEXTAREA object at 0x3221d50, 'estoque_max': gluon.html.INPUT object at 0x32217d0, 'fornecedor': gluon.html.SELECT object at 0x3221b10, 'unidade': gluon.html.INPUT object at 0x3221510, 'codigo': gluon.html.INPUT object at 0x32210d0, 'ativo': gluon.html.INPUT object at 0x32215d0, 'id': '', 'descricao': gluon.html.INPUT object at 0x31f3fd0} Is it expected? Regards, Tito -- Linux User #387870 . _/_õ|__| ..º[ .-.___.-._| . . . . .__( o)__( o).:___ -- --- 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.
[web2py] Re: Custom form won't submit.
{{request_details_form.custom.end}} should be {{=request_details_form.custom.end}} On Thursday, 7 February 2013 05:58:45 UTC-6, Andrew Buchan wrote: Hello, I'm using a form.custom, but clicking on submit doesn't trigger validation or submission. The page just refreshes. The code below always results in 'dont know' at the response.flash... Controller: ... fields = [..] request_details_form = SQLFORM(db.capacity_request, fields=fields) # testing to see if any of these happen on submit... always come up as 'dont know'... if request_details_form.process().accepted: response.flash = 'processed' elif request_details_form.errors: response.flash = 'errors' elif request_details_form.accepts(request.vars, session, dbio=False): response.flash = 'accepted' else: response.flash = 'dont know' return dict(request_details_form=request_details_form) View: . {{=request_details_form.custom.begin}} table id=request_details_table !-- Form won't necessarily include all fields -- {{for field_name in ['team', 'raised_on', 'raised_by', 'contract', 'client', 'owner', 'required_by', 'requested_hours', 'output_formats', 'rechargeable_to_client', 'comments', 'lbg_property_code', 'has_project_been_set_up_on_Doc_Ex', 'has_project_mailbox_been_set_up', 'actual_return_date']: }} {{if request_details_form.custom.widget.has_key(field_name):}} tr td{{=request_details_form.custom.label[field_name]}}/td td{{=request_details_form.custom.widget[field_name]}}/td /tr {{pass}} {{pass}} !-- form doesn't have submit button in view mode... -- {{if request_details_form.custom.submit:}} tr tdlabelgo: /label/td td{{=request_details_form.custom.submit}}/td /tr {{pass}} /table {{request_details_form.custom.end}} The form displays fine, it just won't submit. Anyone have any ideas? Also why should I use form.process.accepts() instead of form.accepts (I saw that advice somewhere relating to custom forms) Using version 2.3.2. Thanks, Andy. -- --- 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.
Re: [web2py] Re: Custom form delete Crud checkbox
On Wed, Dec 26, 2012 at 5:55 AM, Alan Etkin spame...@gmail.com wrote: form.custom.deletable In this case there is an error in book : {{=form.custom.delete}} At the end of the section custom form : http://web2py.com/books/default/chapter/29/07#Custom-forms Just above CSS Conventions. Richard --
Re: [web2py] Re: Custom form delete Crud checkbox
this was fixed in trunk some time ago: self.custom.delete = self.custom.deletable = '' On Monday, 21 January 2013 09:55:09 UTC-6, Richard wrote: On Wed, Dec 26, 2012 at 5:55 AM, Alan Etkin spam...@gmail.comjavascript: wrote: form.custom.deletable In this case there is an error in book : {{=form.custom.delete}} At the end of the section custom form : http://web2py.com/books/default/chapter/29/07#Custom-forms Just above CSS Conventions. Richard --
[web2py] Re: Custom form delete Crud checkbox
El martes, 25 de diciembre de 2012 23:35:21 UTC-3, Massimo Di Pierro escribió: I am not convinced. It is in form.custom.delete why does it need to be also in form.custom.delete_this_record Perhaps in web3py we can rename it but why have it in two places in web2py? With the trunk version you can access a sqlform delete checkbox with: form.custom.deletable for me, form.custom.delete doesn't work I thought that adding the reference to the form field in custom would add consistency with the form.custom.fieldname syntax preserving the current attribute name for avoiding backwards compatibility issues. Anyway, if the access naming is properly documented in the manual, it's not really relevant (and the .deletable name seems to have been used since about 2009) --
[web2py] Re: Custom form delete Crud checkbox
El lunes, 24 de diciembre de 2012 19:09:30 UTC-3, Massimo Di Pierro escribió: I just added this to the web2py book in trunk. Will push it tomorrow. Since the name in the default form is delete_this_record, shouldn't this be found in form.custom.delete_this_record also? --
[web2py] Re: Custom form delete Crud checkbox
Since the name in the default form is delete_this_record, shouldn't this be found in form.custom.delete_this_record also? In case it should, here is a patch for allowing queries to the deletable widget by it's form name -- diff -r 13d7e5ff851d gluon/sqlhtml.py --- a/gluon/sqlhtml.py Tue Dec 25 12:21:08 2012 -0600 +++ b/gluon/sqlhtml.py Tue Dec 25 19:38:32 2012 -0300 @@ -235,7 +235,6 @@ raise SyntaxError( 'widget cannot determine options of %s' % field) opts = [OPTION(v, _value=k) for (k, v) in options] - return SELECT(*opts, **attr) @@ -1154,7 +1153,8 @@ _id=self.FIELDKEY_DELETE_RECORD + SQLFORM.ID_LABEL_SUFFIX), widget, col3.get(self.FIELDKEY_DELETE_RECORD, ''))) -self.custom.deletable = widget +self.custom.deletable = \ +self.custom[self.FIELDNAME_REQUEST_DELETE] = widget # when writable, add submit button self.custom.submit = ''
[web2py] Re: Custom form delete Crud checkbox
I am not convinced. It is in form.custom.delete why does it need to be also in form.custom.delete_this_record Perhaps in web3py we can rename it but why have it in two places in web2py? contains things which are not fields. The On Tuesday, 25 December 2012 16:43:47 UTC-6, Alan Etkin wrote: Since the name in the default form is delete_this_record, shouldn't this be found in form.custom.delete_this_record also? In case it should, here is a patch for allowing queries to the deletable widget by it's form name --
[web2py] Re: Custom form delete Crud checkbox
Massimo, Do you know if the documentation has been updated to document this property? I got here because I couldn't find this in the book in the first place. Thanks, Carlos. On Tuesday, February 22, 2011 11:28:57 PM UTC-3, Massimo Di Pierro wrote: {{=form.custom.deletable}} it is not a widget. I agree that the name is not the most appropriate. On Feb 22, 4:07 pm, greenpoise danel.sega...@gmail.com wrote: I dont know where my posts are going...anyways, I have a Crud custom form. Its set but I am also customizing the layout of the crud update form and I cant seem to get the delete checkbox...how would I go for that?? {{=form.custom.widget.? tried: {{=form.custom.widget.delete/checkbox/delete_record/etcetcetc thanks d --
[web2py] Re: Custom form delete Crud checkbox
I just added this to the web2py book in trunk. Will push it tomorrow. On Monday, 24 December 2012 15:06:28 UTC-6, Carlos Dañel Ferreyra wrote: Massimo, Do you know if the documentation has been updated to document this property? I got here because I couldn't find this in the book in the first place. Thanks, Carlos. On Tuesday, February 22, 2011 11:28:57 PM UTC-3, Massimo Di Pierro wrote: {{=form.custom.deletable}} it is not a widget. I agree that the name is not the most appropriate. On Feb 22, 4:07 pm, greenpoise danel.sega...@gmail.com wrote: I dont know where my posts are going...anyways, I have a Crud custom form. Its set but I am also customizing the layout of the crud update form and I cant seem to get the delete checkbox...how would I go for that?? {{=form.custom.widget.? tried: {{=form.custom.widget.delete/checkbox/delete_record/etcetcetc thanks d --
[web2py] Re: custom form validation doesn't work
Hello Jonas, Can you show us your custom form, the one that does not work. Validation and form processing are done before the view is execued therefore it cannot affect form validation and processing. perhaps that is something in the custom form that prevents error messages from being displayed. I do not understand the second question. The index function returns all records for each table. Massimo On Saturday, 15 December 2012 17:27:51 UTC-6, jonas wrote: Hi. I have a default form that is passed in view: {{=form}} using this validation and insertion works. but when I use a custom form none of that works. why? Also form.process().accepted works only when using default form. My second question is: when submitting the form I redirect to index, and all entries in the db are returned. Is that because i reuse the index function? Is there any way to clear all fields after a successful submit? the code: default.py: def index(): query=db.blog.id0 res=db(query).select(orderby=~db.blog.date) query=db.about.id0 about=db(query).select() query=db.comments.post_id0 com=db(query).select(orderby=~db.comments.created_on) return dict(res=res,about=about,com=com,message=T('Everything should be made as simple as possible, but not simpler')) def comment(): create comment form. Every comment is id locked to the specific post post=db(db.blog.id==request.args(0)).select().first() db.comments.post_id.default=post.id form=crud.create(db.comments) if form.process().accepted: print 'form accepted' redirect(URL('index')) else: print 'not accepted' return dict(form=form) index.html: {{=A(TAG.i(_class=icon-plus-sign), _rel=tooltip, _title=testing, _class=btn, _href='#', _onclick=jQuery('#uc').toggle();)}} div id=uc {{=LOAD('default','comment.load',args=result.id,ajax=True)}} /div comment.load: {{=form}} thanks --
Re: [web2py] Re: custom form validation doesn't work
here is the custom form: {{=form.custom.begin}} div class=row h5date: /h5{{=form.custom.widget.created_on}} /div div class=row h5name: /h5{{=form.custom.widget.created_by}} /div div class=row h5mail: /h5{{=form.custom.widget.mail}} /div div class=row h5link: /h5{{=form.custom.widget.link}} /div div class=row h5comment:/h5{{=form.custom.widget.comment}} /div {{=form.custom.submit}} {{=form.custom.end}} The second question is as follows: when the form is filled and submitted, it should be clean, i.e no text in it or something else that indicates that the submission was successful and possible collapsed to. It is true that the redirect(index) returns data from the data base but I want to avoid that in this case, so another form of redirect would be better. On Sun, Dec 16, 2012 at 3:35 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Hello Jonas, Can you show us your custom form, the one that does not work. Validation and form processing are done before the view is execued therefore it cannot affect form validation and processing. perhaps that is something in the custom form that prevents error messages from being displayed. I do not understand the second question. The index function returns all records for each table. Massimo On Saturday, 15 December 2012 17:27:51 UTC-6, jonas wrote: Hi. I have a default form that is passed in view: {{=form}} using this validation and insertion works. but when I use a custom form none of that works. why? Also form.process().accepted works only when using default form. My second question is: when submitting the form I redirect to index, and all entries in the db are returned. Is that because i reuse the index function? Is there any way to clear all fields after a successful submit? the code: default.py: def index(): query=db.blog.id0 res=db(query).select(orderby=~db.blog.date) query=db.about.id0 about=db(query).select() query=db.comments.post_id0 com=db(query).select(orderby=~db.comments.created_on) return dict(res=res,about=about,com=com,message=T('Everything should be made as simple as possible, but not simpler')) def comment(): create comment form. Every comment is id locked to the specific post post=db(db.blog.id==request.args(0)).select().first() db.comments.post_id.default=post.id form=crud.create(db.comments) if form.process().accepted: print 'form accepted' redirect(URL('index')) else: print 'not accepted' return dict(form=form) index.html: {{=A(TAG.i(_class=icon-plus-sign), _rel=tooltip, _title=testing, _class=btn, _href='#', _onclick=jQuery('#uc').toggle();)}} div id=uc {{=LOAD('default','comment.load',args=result.id,ajax=True)}} /div comment.load: {{=form}} thanks -- --
Re: [web2py] Re: custom form validation doesn't work
This should work. I do not see why it does not work. Can you email me, perhaps privately, an example app so I can reproduce it? On Sunday, 16 December 2012 09:26:54 UTC-6, jonas wrote: here is the custom form: {{=form.custom.begin}} div class=row h5date: /h5{{=form.custom.widget.created_on}} /div div class=row h5name: /h5{{=form.custom.widget.created_by}} /div div class=row h5mail: /h5{{=form.custom.widget.mail}} /div div class=row h5link: /h5{{=form.custom.widget.link}} /div div class=row h5comment:/h5{{=form.custom.widget.comment}} /div {{=form.custom.submit}} {{=form.custom.end}} The second question is as follows: when the form is filled and submitted, it should be clean, i.e no text in it or something else that indicates that the submission was successful and possible collapsed to. It is true that the redirect(index) returns data from the data base but I want to avoid that in this case, so another form of redirect would be better. On Sun, Dec 16, 2012 at 3:35 PM, Massimo Di Pierro massimo@gmail.com javascript: wrote: Hello Jonas, Can you show us your custom form, the one that does not work. Validation and form processing are done before the view is execued therefore it cannot affect form validation and processing. perhaps that is something in the custom form that prevents error messages from being displayed. I do not understand the second question. The index function returns all records for each table. Massimo On Saturday, 15 December 2012 17:27:51 UTC-6, jonas wrote: Hi. I have a default form that is passed in view: {{=form}} using this validation and insertion works. but when I use a custom form none of that works. why? Also form.process().accepted works only when using default form. My second question is: when submitting the form I redirect to index, and all entries in the db are returned. Is that because i reuse the index function? Is there any way to clear all fields after a successful submit? the code: default.py: def index(): query=db.blog.id0 res=db(query).select(orderby=~db.blog.date) query=db.about.id0 about=db(query).select() query=db.comments.post_id0 com=db(query).select(orderby=~db.comments.created_on) return dict(res=res,about=about,com=com,message=T('Everything should be made as simple as possible, but not simpler')) def comment(): create comment form. Every comment is id locked to the specific post post=db(db.blog.id==request.args(0)).select().first() db.comments.post_id.default=post.id form=crud.create(db.comments) if form.process().accepted: print 'form accepted' redirect(URL('index')) else: print 'not accepted' return dict(form=form) index.html: {{=A(TAG.i(_class=icon-plus-sign), _rel=tooltip, _title=testing, _class=btn, _href='#', _onclick=jQuery('#uc').toggle();)}} div id=uc {{=LOAD('default','comment.load',args=result.id,ajax=True)}} /div comment.load: {{=form}} thanks -- --
Re: [web2py] Re: custom form validation doesn't work
I send the app to your gmail address. On Sun, Dec 16, 2012 at 4:35 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: This should work. I do not see why it does not work. Can you email me, perhaps privately, an example app so I can reproduce it? On Sunday, 16 December 2012 09:26:54 UTC-6, jonas wrote: here is the custom form: {{=form.custom.begin}} div class=row h5date: /h5{{=form.custom.widget.created_on}} /div div class=row h5name: /h5{{=form.custom.widget.created_by}} /div div class=row h5mail: /h5{{=form.custom.widget.mail}} /div div class=row h5link: /h5{{=form.custom.widget.link}} /div div class=row h5comment:/h5{{=form.custom.widget.comment}} /div {{=form.custom.submit}} {{=form.custom.end}} The second question is as follows: when the form is filled and submitted, it should be clean, i.e no text in it or something else that indicates that the submission was successful and possible collapsed to. It is true that the redirect(index) returns data from the data base but I want to avoid that in this case, so another form of redirect would be better. On Sun, Dec 16, 2012 at 3:35 PM, Massimo Di Pierro massimo@gmail.com wrote: Hello Jonas, Can you show us your custom form, the one that does not work. Validation and form processing are done before the view is execued therefore it cannot affect form validation and processing. perhaps that is something in the custom form that prevents error messages from being displayed. I do not understand the second question. The index function returns all records for each table. Massimo On Saturday, 15 December 2012 17:27:51 UTC-6, jonas wrote: Hi. I have a default form that is passed in view: {{=form}} using this validation and insertion works. but when I use a custom form none of that works. why? Also form.process().accepted works only when using default form. My second question is: when submitting the form I redirect to index, and all entries in the db are returned. Is that because i reuse the index function? Is there any way to clear all fields after a successful submit? the code: default.py: def index(): query=db.blog.id0 res=db(query).select(orderby=~db.blog.date) query=db.about.id0 about=db(query).select() query=db.comments.post_id0 com=db(query).select(orderby=~db.comments.created_on) return dict(res=res,about=about,com=com,message=T('Everything should be made as simple as possible, but not simpler')) def comment(): create comment form. Every comment is id locked to the specific post post=db(db.blog.id==request.args(0)).select().first() db.comments.post_id.default=post.id form=crud.create(db.comments) if form.process().accepted: print 'form accepted' redirect(URL('index')) else: print 'not accepted' return dict(form=form) index.html: {{=A(TAG.i(_class=icon-plus-sign), _rel=tooltip, _title=testing, _class=btn, _href='#', _onclick=jQuery('#uc').toggle();)}} div id=uc {{=LOAD('default','comment.load',args=result.id,ajax=True)}} /div comment.load: {{=form}} thanks -- -- --
Re: [web2py] Re: custom form validation
ok. another thing is that if I use a regular form, {{=form}}, then validation works but not if I use the custom form. Also form.process() works, so the problem seems to be related to custom forms. On Sat, Dec 15, 2012 at 4:06 AM, Anthony abasta...@gmail.com wrote: form=crud.create(db.comments) if form.process().accepted: Crud and form.process() do not go together. Crud is a higher level interface and automatically handles form processing. Once you call crud.create(), the form is already processed -- processing it the second time will not work (the formkey token used to protect against CSRF attacks and double submission is only good for one submission). Anthony -- --
[web2py] Re: custom form validation
form=crud.create(db.comments) if form.process().accepted: Crud and form.process() do not go together. Crud is a higher level interface and automatically handles form processing. Once you call crud.create(), the form is already processed -- processing it the second time will not work (the formkey token used to protect against CSRF attacks and double submission is only good for one submission). Anthony --
[web2py] Re: Custom form with default values...
You could set the readable and writable attributes of the fields you want to hide to False. Another option is to use SQLFORM instead of Crud and pass the fields argument with a list of fields to include. In this case, SQLFORM is probably just as easy to use as Crud. bio_form = SQLFORM(db.event_attender, fields=['show_attendance', 'bio_text' ]).process() Anthony On Wednesday, May 16, 2012 3:43:09 AM UTC-4, encompass wrote: Many values I don't need to show in the view so I have done this: def join(): ''' NOTES:Covers the event bio and any payments if needed. ''' event_details = db.event[request.args(0)] if not event_details: redirect(URL('default', 'index')) attender_count = db(db.event_attender.event == request.args(0)).count() event_full = attender_count = event_details.maximum_attendance payment_needed = event_details.ticket_cost db.event_attender.event.default = request.args(0) bio_form = crud.create(db.event_attender) return dict(event_full = event_full, payment_needed = payment_needed, event_details = event_details, bio_form = bio_form) With this in the view: div {{=bio_form.custom.begin}} Show Attendance: {{=bio_form.custom.widget.show_attendance}} {{=bio_form.custom.widget.bio_text}} {{=bio_form.custom.submit}} {{=bio_form.custom.end}}/div If I print the form with {{=bio_form}} it works just fine, but I see all the extra data fields. Is there a way to fix this? For a golden star I have the model as follows: # -*- coding: utf-8 -*- db.define_table('event_attender', Field('attender', db.auth_user), Field('event', db.event), Field('role', 'string', default=attender), Field('status', 'string', default=not_present), Field('show_attendance', 'boolean', default=True), Field('bio_text', 'text'), Field('QR_quick_connect', 'string') ) db.event_attender.role.requires = IS_IN_SET([attender, 'admin', 'organizer', 'speaker', 'booth']) db.event_attender.status.requires = IS_IN_SET([present, 'not_present', 'banned']) db.event_attender.attender.requires = IS_IN_DB(db,db.auth_user.id,'%(nickname)s') db.event_attender.event.requires = IS_IN_DB(db,db.event.id,'%(name)s') db.event_attender.bio_text.widget = lambda field,value: \ SQLFORM.widgets.text.widget(field,value,_class='text nicedit', _style=color:red) if auth.is_logged_in(): db.event_attender.attender.default = auth.user.id Best Regards, Jason Brower
Re: [web2py] Re: Custom Form Action empty
On Mon, Oct 17, 2011 at 03:11, Anthony abasta...@gmail.com wrote: Now that I think about it, this is overkill. It's just a simple form tag (no custom web2py classes or attributes), so probably just as easy to hand code the HTML (which will also be more clear). @From Massimo: you can simply use: form ... instead of {{=XML(form.custom.begin.replace())}} my solution is: {{=XML(form.custom.begin.replace('action=', 'action=people'))}} {{=DIV(DIV('Name:',_id='two'),DIV(form.custom.widget.name ,_id='three'),DIV(form.custom.submit,_id='for'),_id='one')}} {{=form.custom.end}} maybe this is not the best practice - but after all at the end everything is HTML source I get next HTML source with three line in view: form action=people enctype=multipart/form-data method=post div id=one div id=twoName:/div div id=three input class=string id=person_name name=name type=text value=/ /div div id=for input type=submit value=Submit/ /div /div div class=hidden input name=_next type=hidden value=/moje0/default/people/ input name=_formkey type=hidden value=e0b5af7b-0cad-483b-979d-4f8b014e1d3a/ input name=_formname type=hidden value=person/None/ /div /form If I use HTML form or mentioned my example result is same. *But how in HTML form get hidden fields, and ** value=e0b5af7b-0cad-483b-979d-4f8b014e1d3a** - and this value it is changed after every form submit?* I don't know how web2py work, but I can see that is hard coding reduced on minimum and I get my need very fast. And after all now it is only 10 (but not more than 14) days how I use web2py, or how I heard for web2py. I tray to learn what is happens in web2py when I put some code in controler, or view, or model, but it take some time to read and tray some example. And best effect in learning is when you do some examples, and now I do small examples what I can need later, My apologies for my questions what sometimes are not ease to understand but after all I'm beginner at web2py. Thanks - - Miroslav Gojic - - On Sunday, October 16, 2011 6:05:41 PM UTC-4, miroslavgojic wrote: After some time and several trays I get solution in view for custom form I used {{=XML(form.custom.begin.**replace('action=', 'action=people'))}} and it produce code in source: form action=people enctype=multipart/form-data method=post and my form now work and I have not empty action field Thanks everybody for help - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 19:41, Anthony abas...@gmail.com wrote: I see the problem -- setting the '_action' attribute after the form is created doesn't affect form.custom.begin, which is what you are using. Instead, try this in the view: {{=form.custom.begin.replace('**action=', 'action=%s' % URL()}} URL() should generate the URL of the current action (though it won't include args and vars, so you'll have to add those explicitly if your URL happens to use them). However, I'm not sure it's necessary to have a non-empty action for valid HTML5 -- see #9 here: http://www.whatwg.org/** specs/web-apps/current-work/**multipage/association-of-** controls-and-forms.html#form-**submission-algorithmhttp://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#form-submission-algorithm. An empty action appears to be valid. Anthony On Sunday, October 16, 2011 12:50:29 PM UTC-4, miroslavgojic wrote: I try next example and all mentioned options: def people(): form = crud.create(db.person,next=**URL**('people'),message=T(**record created)) form['_action'] = URL('index') return dict(form = form) but my action field in form is empty. What do you mean the action field is empty? When I try the exact code above, I get the following in the resulting source html: form action=/testapp/default/index** enctype=multipart/form-data method=post Are you expecting something else? - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 16:09, Anthony aba...@gmail.com wrote: On Sunday, October 16, 2011 3:23:01 AM UTC-4, miroslavgojic wrote: I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('**index**')) form.attributes.update(_**action**=URL('index')) but it is not happened anything, What exactly happened? I assume this does change the form action as expected, but then nothing happens when you submit the form? When you change the form action, the form will get submitted to that action. If you submit the form to 'index', then your 'index' function will have to process the submitted form -- if there's no code in your 'index' function to do so, then nothing will happen. In web2py, forms are typically self-submitting (i.e., submitted to the action that generated them). Is there a reason you want to submit the form to a different action? and if I change my value I just get error form.update(_action=my_value) - this make error What is my_value? Is it a
Re: [web2py] Re: Custom Form Action empty
On Monday, October 17, 2011 2:25:02 AM UTC-4, miroslavgojic wrote: If I use HTML form or mentioned my example result is same. *But how in HTML form get hidden fields, and ** value=e0b5af7b-0cad-483b-979d-4f8b014e1d3a** - and this value it is changed after every form submit?* You should let web2py handle creating the _formkey, _formname, and _next hidden fields. We were only recommending manually coding the opening form tag, not the entire form. See http://web2py.com/book/default/chapter/07#Hidden-fields for more details about the hidden fields. They are generated by the form.accepts() method (which crud.create ultimately calls). The _formkey field, in particular, is a one-time token that is used to protect against double form submissions and cross-site request forgery attacks (the key is also stored in the session and must match the value stored in the session when submitted). Anthony
[web2py] Re: Custom Form Action empty
Looking at the source, it seems possible to add FORM **attributes to crud just like SQLFORM. Any cons?.
Re: [web2py] Re: Custom Form Action empty
I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('index')) form.attributes.update(_action=URL('index')) but it is not happened anything, and if I change my value I just get error form.update(_action=my_value) - this make error In view after beginning of form.custom.start I tray next similar code {{=form['_action'] = URL(index')}} but nothing work, or I get error or work but my attribute action value it stay empty - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 00:37, Anthony abasta...@gmail.com wrote: form['_action'] = your_value # e.g., URL('controller', 'function', ...)
[web2py] Re: Custom Form Action empty
form['_action'] = URL('index') not form['_action'] = URL(index') On Oct 16, 2:23 am, Miroslav Gojic miroslavgo...@gmail.com wrote: I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('index')) form.attributes.update(_action=URL('index')) but it is not happened anything, and if I change my value I just get error form.update(_action=my_value) - this make error In view after beginning of form.custom.start I tray next similar code {{=form['_action'] = URL(index')}} but nothing work, or I get error or work but my attribute action value it stay empty - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 00:37, Anthony abasta...@gmail.com wrote: form['_action'] = your_value # e.g., URL('controller', 'function', ...)
Re: [web2py] Re: Custom Form Action empty
On Sunday, October 16, 2011 3:23:01 AM UTC-4, miroslavgojic wrote: I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('index')) form.attributes.update(_action=URL('index')) but it is not happened anything, What exactly happened? I assume this does change the form action as expected, but then nothing happens when you submit the form? When you change the form action, the form will get submitted to that action. If you submit the form to 'index', then your 'index' function will have to process the submitted form -- if there's no code in your 'index' function to do so, then nothing will happen. In web2py, forms are typically self-submitting (i.e., submitted to the action that generated them). Is there a reason you want to submit the form to a different action? and if I change my value I just get error form.update(_action=my_value) - this make error What is my_value? Is it a URL? In view after beginning of form.custom.start I tray next similar code {{=form['_action'] = URL(index')}} I assume you mean form.custom.begin? Anyway, it will not work to change the form action after that because form.custom.begin actually inserts the form tag with the action specified -- so changing the action after will not affect the way the form is serialized. Anthony
Re: [web2py] Re: Custom Form Action empty
Is your goal simply to make sure the user gets redirected to 'index' after submitting the form? If that's the case, then you don't have to set a custom form action at all. If you leave the form action empty, the form will be submitted back to the action that generated it (which is how web2py form processing typically works). By specifying the 'next' argument of crud.create(), crud will automatically redirect the user to 'index' after a successful form submission. Anthony On Sunday, October 16, 2011 10:09:04 AM UTC-4, Anthony wrote: On Sunday, October 16, 2011 3:23:01 AM UTC-4, miroslavgojic wrote: I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('index')) form.attributes.update(_action=URL('index')) but it is not happened anything, What exactly happened? I assume this does change the form action as expected, but then nothing happens when you submit the form? When you change the form action, the form will get submitted to that action. If you submit the form to 'index', then your 'index' function will have to process the submitted form -- if there's no code in your 'index' function to do so, then nothing will happen. In web2py, forms are typically self-submitting (i.e., submitted to the action that generated them). Is there a reason you want to submit the form to a different action? and if I change my value I just get error form.update(_action=my_value) - this make error What is my_value? Is it a URL? In view after beginning of form.custom.start I tray next similar code {{=form['_action'] = URL(index')}} I assume you mean form.custom.begin? Anyway, it will not work to change the form action after that because form.custom.begin actually inserts the form tag with the action specified -- so changing the action after will not affect the way the form is serialized. Anthony
Re: [web2py] Re: Custom Form Action empty
My errors in previews post: form['_action'] = URL(index') - my error - correct is - form['_action'] = URL('index') my_value - is mean - URL('controller') #this can be controller or index or some value. From last Anthony replay I figure out why it can't work from view but how to resolve this in controller. this is my form definition in controller: def people(): form = crud.create(db.person,next=URL('people'),message=T(record created)) return dict(form = form) I try next example and all mentioned options: def people(): form = crud.create(db.person,next=URL('people'),message=T(record created)) form['_action'] = URL('index') return dict(form = form) but my action field in form is empty. - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 16:09, Anthony abasta...@gmail.com wrote: On Sunday, October 16, 2011 3:23:01 AM UTC-4, miroslavgojic wrote: I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('index')) form.attributes.update(_action=URL('index')) but it is not happened anything, What exactly happened? I assume this does change the form action as expected, but then nothing happens when you submit the form? When you change the form action, the form will get submitted to that action. If you submit the form to 'index', then your 'index' function will have to process the submitted form -- if there's no code in your 'index' function to do so, then nothing will happen. In web2py, forms are typically self-submitting (i.e., submitted to the action that generated them). Is there a reason you want to submit the form to a different action? and if I change my value I just get error form.update(_action=my_value) - this make error What is my_value? Is it a URL? In view after beginning of form.custom.start I tray next similar code {{=form['_action'] = URL(index')}} I assume you mean form.custom.begin? Anyway, it will not work to change the form action after that because form.custom.begin actually inserts the form tag with the action specified -- so changing the action after will not affect the way the form is serialized. Anthony
Re: [web2py] Re: Custom Form Action empty
My custom form work fine, After one day I work to make my HTML5 valid on end it only action in form make error. And after that I reed all what I can find but not helped me. And on my previews post I put my actual and next form definition in controller (people or index is not to much important where is redirected) I need only to get something in action field in form. If is this possible in form.custom.begin - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 18:50, Miroslav Gojic miroslavgo...@gmail.com wrote: My errors in previews post: form['_action'] = URL(index') - my error - correct is - form['_action'] = URL('index') my_value - is mean - URL('controller') #this can be controller or index or some value. From last Anthony replay I figure out why it can't work from view but how to resolve this in controller. this is my form definition in controller: def people(): form = crud.create(db.person,next=URL('people'),message=T(record created)) return dict(form = form) I try next example and all mentioned options: def people(): form = crud.create(db.person,next=URL('people'),message=T(record created)) form['_action'] = URL('index') return dict(form = form) but my action field in form is empty. - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 16:09, Anthony abasta...@gmail.com wrote: On Sunday, October 16, 2011 3:23:01 AM UTC-4, miroslavgojic wrote: I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('index')) form.attributes.update(_action=URL('index')) but it is not happened anything, What exactly happened? I assume this does change the form action as expected, but then nothing happens when you submit the form? When you change the form action, the form will get submitted to that action. If you submit the form to 'index', then your 'index' function will have to process the submitted form -- if there's no code in your 'index' function to do so, then nothing will happen. In web2py, forms are typically self-submitting (i.e., submitted to the action that generated them). Is there a reason you want to submit the form to a different action? and if I change my value I just get error form.update(_action=my_value) - this make error What is my_value? Is it a URL? In view after beginning of form.custom.start I tray next similar code {{=form['_action'] = URL(index')}} I assume you mean form.custom.begin? Anyway, it will not work to change the form action after that because form.custom.begin actually inserts the form tag with the action specified -- so changing the action after will not affect the way the form is serialized. Anthony
Re: [web2py] Re: Custom Form Action empty
I see the problem -- setting the '_action' attribute after the form is created doesn't affect form.custom.begin, which is what you are using. Instead, try this in the view: {{=form.custom.begin.replace('action=', 'action=%s' % URL()}} URL() should generate the URL of the current action (though it won't include args and vars, so you'll have to add those explicitly if your URL happens to use them). However, I'm not sure it's necessary to have a non-empty action for valid HTML5 -- see #9 here: http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#form-submission-algorithm. An empty action appears to be valid. Anthony On Sunday, October 16, 2011 12:50:29 PM UTC-4, miroslavgojic wrote: I try next example and all mentioned options: def people(): form = crud.create(db.person,next=URL('people'),message=T(record created)) form['_action'] = URL('index') return dict(form = form) but my action field in form is empty. What do you mean the action field is empty? When I try the exact code above, I get the following in the resulting source html: form action=/testapp/default/index enctype=multipart/form-data method= post Are you expecting something else? - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 16:09, Anthony abas...@gmail.com wrote: On Sunday, October 16, 2011 3:23:01 AM UTC-4, miroslavgojic wrote: I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('index')) form.attributes.update(_action=URL('index')) but it is not happened anything, What exactly happened? I assume this does change the form action as expected, but then nothing happens when you submit the form? When you change the form action, the form will get submitted to that action. If you submit the form to 'index', then your 'index' function will have to process the submitted form -- if there's no code in your 'index' function to do so, then nothing will happen. In web2py, forms are typically self-submitting (i.e., submitted to the action that generated them). Is there a reason you want to submit the form to a different action? and if I change my value I just get error form.update(_action=my_value) - this make error What is my_value? Is it a URL? In view after beginning of form.custom.start I tray next similar code {{=form['_action'] = URL(index')}} I assume you mean form.custom.begin? Anyway, it will not work to change the form action after that because form.custom.begin actually inserts the form tag with the action specified -- so changing the action after will not affect the way the form is serialized. Anthony
Re: [web2py] Re: Custom Form Action empty
With empty action field I mean: form action= enctype=multipart/form-data method=post and this is not empty action field form action=/testapp/default/index enctype=multipart/form-data method=post I used this line in my view: {{=form.custom.begin.replace('action=', 'action=%s' % URL('index'))}} and output in source is: lt;form action=quot;/moje0/default/indexquot; enctype=quot;multipart/form-dataquot; method=quot;postquot;gt; and in browser I get this: form action=/moje0/default/index enctype=multipart/form-data method=post just to put this what I see to code and everything is than resolved. Thanks - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 19:41, Anthony abasta...@gmail.com wrote: I see the problem -- setting the '_action' attribute after the form is created doesn't affect form.custom.begin, which is what you are using. Instead, try this in the view: {{=form.custom.begin.replace('action=', 'action=%s' % URL()}} URL() should generate the URL of the current action (though it won't include args and vars, so you'll have to add those explicitly if your URL happens to use them). However, I'm not sure it's necessary to have a non-empty action for valid HTML5 -- see #9 here: http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#form-submission-algorithm. An empty action appears to be valid. Anthony On Sunday, October 16, 2011 12:50:29 PM UTC-4, miroslavgojic wrote: I try next example and all mentioned options: def people(): form = crud.create(db.person,next=URL('people'),message=T(record created)) form['_action'] = URL('index') return dict(form = form) but my action field in form is empty. What do you mean the action field is empty? When I try the exact code above, I get the following in the resulting source html: form action=/testapp/default/index enctype=multipart/form-data method=post Are you expecting something else? - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 16:09, Anthony abas...@gmail.com wrote: On Sunday, October 16, 2011 3:23:01 AM UTC-4, miroslavgojic wrote: I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('index')) form.attributes.update(_action=URL('index')) but it is not happened anything, What exactly happened? I assume this does change the form action as expected, but then nothing happens when you submit the form? When you change the form action, the form will get submitted to that action. If you submit the form to 'index', then your 'index' function will have to process the submitted form -- if there's no code in your 'index' function to do so, then nothing will happen. In web2py, forms are typically self-submitting (i.e., submitted to the action that generated them). Is there a reason you want to submit the form to a different action? and if I change my value I just get error form.update(_action=my_value) - this make error What is my_value? Is it a URL? In view after beginning of form.custom.start I tray next similar code {{=form['_action'] = URL(index')}} I assume you mean form.custom.begin? Anyway, it will not work to change the form action after that because form.custom.begin actually inserts the form tag with the action specified -- so changing the action after will not affect the way the form is serialized. Anthony
Re: [web2py] Re: Custom Form Action empty
And about validation on suggested link it is writhed under point 9 (section 4.10.22.3) *If action is the empty string, let action be the document's address of the form document.* - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 19:41, Anthony abasta...@gmail.com wrote: I see the problem -- setting the '_action' attribute after the form is created doesn't affect form.custom.begin, which is what you are using. Instead, try this in the view: {{=form.custom.begin.replace('action=', 'action=%s' % URL()}} URL() should generate the URL of the current action (though it won't include args and vars, so you'll have to add those explicitly if your URL happens to use them). However, I'm not sure it's necessary to have a non-empty action for valid HTML5 -- see #9 here: http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#form-submission-algorithm . An empty action appears to be valid. Anthony On Sunday, October 16, 2011 12:50:29 PM UTC-4, miroslavgojic wrote: I try next example and all mentioned options: def people(): form = crud.create(db.person,next=URL('people'),message=T(record created)) form['_action'] = URL('index') return dict(form = form) but my action field in form is empty. What do you mean the action field is empty? When I try the exact code above, I get the following in the resulting source html: form action=/testapp/default/index enctype=multipart/form-data method=post Are you expecting something else? - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 16:09, Anthony abas...@gmail.com wrote: On Sunday, October 16, 2011 3:23:01 AM UTC-4, miroslavgojic wrote: I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('index')) form.attributes.update(_action=URL('index')) but it is not happened anything, What exactly happened? I assume this does change the form action as expected, but then nothing happens when you submit the form? When you change the form action, the form will get submitted to that action. If you submit the form to 'index', then your 'index' function will have to process the submitted form -- if there's no code in your 'index' function to do so, then nothing will happen. In web2py, forms are typically self-submitting (i.e., submitted to the action that generated them). Is there a reason you want to submit the form to a different action? and if I change my value I just get error form.update(_action=my_value) - this make error What is my_value? Is it a URL? In view after beginning of form.custom.start I tray next similar code {{=form['_action'] = URL(index')}} I assume you mean form.custom.begin? Anyway, it will not work to change the form action after that because form.custom.begin actually inserts the form tag with the action specified -- so changing the action after will not affect the way the form is serialized. Anthony
Re: [web2py] Re: Custom Form Action empty
After some time and several trays I get solution in view for custom form I used {{=XML(form.custom.begin.replace('action=', 'action=people'))}} and it produce code in source: form action=people enctype=multipart/form-data method=post and my form now work and I have not empty action field Thanks everybody for help - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 19:41, Anthony abasta...@gmail.com wrote: I see the problem -- setting the '_action' attribute after the form is created doesn't affect form.custom.begin, which is what you are using. Instead, try this in the view: {{=form.custom.begin.replace('action=', 'action=%s' % URL()}} URL() should generate the URL of the current action (though it won't include args and vars, so you'll have to add those explicitly if your URL happens to use them). However, I'm not sure it's necessary to have a non-empty action for valid HTML5 -- see #9 here: http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#form-submission-algorithm. An empty action appears to be valid. Anthony On Sunday, October 16, 2011 12:50:29 PM UTC-4, miroslavgojic wrote: I try next example and all mentioned options: def people(): form = crud.create(db.person,next=**URL('people'),message=T(**record created)) form['_action'] = URL('index') return dict(form = form) but my action field in form is empty. What do you mean the action field is empty? When I try the exact code above, I get the following in the resulting source html: form action=/testapp/default/index enctype=multipart/form-data method =post Are you expecting something else? - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 16:09, Anthony abas...@gmail.com wrote: On Sunday, October 16, 2011 3:23:01 AM UTC-4, miroslavgojic wrote: I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('**index')) form.attributes.update(_**action=URL('index')) but it is not happened anything, What exactly happened? I assume this does change the form action as expected, but then nothing happens when you submit the form? When you change the form action, the form will get submitted to that action. If you submit the form to 'index', then your 'index' function will have to process the submitted form -- if there's no code in your 'index' function to do so, then nothing will happen. In web2py, forms are typically self-submitting (i.e., submitted to the action that generated them). Is there a reason you want to submit the form to a different action? and if I change my value I just get error form.update(_action=my_value) - this make error What is my_value? Is it a URL? In view after beginning of form.custom.start I tray next similar code {{=form['_action'] = URL(index')}} I assume you mean form.custom.begin? Anyway, it will not work to change the form action after that because form.custom.begin actually inserts the form tag with the action specified -- so changing the action after will not affect the way the form is serialized. Anthony
[web2py] Re: Custom Form Action empty
you can simply use: form ... instead of {{=XML(form.custom.begin.replace())}} On Oct 16, 5:05 pm, Miroslav Gojic miroslavgo...@gmail.com wrote: After some time and several trays I get solution in view for custom form I used {{=XML(form.custom.begin.replace('action=', 'action=people'))}} and it produce code in source: form action=people enctype=multipart/form-data method=post and my form now work and I have not empty action field Thanks everybody for help - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 19:41, Anthony abasta...@gmail.com wrote: I see the problem -- setting the '_action' attribute after the form is created doesn't affect form.custom.begin, which is what you are using. Instead, try this in the view: {{=form.custom.begin.replace('action=', 'action=%s' % URL()}} URL() should generate the URL of the current action (though it won't include args and vars, so you'll have to add those explicitly if your URL happens to use them). However, I'm not sure it's necessary to have a non-empty action for valid HTML5 -- see #9 here: http://www.whatwg.org/specs/web-apps/current-work/multipage/associati An empty action appears to be valid. Anthony On Sunday, October 16, 2011 12:50:29 PM UTC-4, miroslavgojic wrote: I try next example and all mentioned options: def people(): form = crud.create(db.person,next=**URL('people'),message=T(**record created)) form['_action'] = URL('index') return dict(form = form) but my action field in form is empty. What do you mean the action field is empty? When I try the exact code above, I get the following in the resulting source html: form action=/testapp/default/index enctype=multipart/form-data method =post Are you expecting something else? - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 16:09, Anthony abas...@gmail.com wrote: On Sunday, October 16, 2011 3:23:01 AM UTC-4, miroslavgojic wrote: I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('**index')) form.attributes.update(_**action=URL('index')) but it is not happened anything, What exactly happened? I assume this does change the form action as expected, but then nothing happens when you submit the form? When you change the form action, the form will get submitted to that action. If you submit the form to 'index', then your 'index' function will have to process the submitted form -- if there's no code in your 'index' function to do so, then nothing will happen. In web2py, forms are typically self-submitting (i.e., submitted to the action that generated them). Is there a reason you want to submit the form to a different action? and if I change my value I just get error form.update(_action=my_value) - this make error What is my_value? Is it a URL? In view after beginning of form.custom.start I tray next similar code {{=form['_action'] = URL(index')}} I assume you mean form.custom.begin? Anyway, it will not work to change the form action after that because form.custom.begin actually inserts the form tag with the action specified -- so changing the action after will not affect the way the form is serialized. Anthony
Re: [web2py] Re: Custom Form Action empty
Now that I think about it, this is overkill. It's just a simple form tag (no custom web2py classes or attributes), so probably just as easy to hand code the HTML (which will also be more clear). On Sunday, October 16, 2011 6:05:41 PM UTC-4, miroslavgojic wrote: After some time and several trays I get solution in view for custom form I used {{=XML(form.custom.begin.replace('action=', 'action=people'))}} and it produce code in source: form action=people enctype=multipart/form-data method=post and my form now work and I have not empty action field Thanks everybody for help - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 19:41, Anthony abas...@gmail.com wrote: I see the problem -- setting the '_action' attribute after the form is created doesn't affect form.custom.begin, which is what you are using. Instead, try this in the view: {{=form.custom.begin.replace('action=', 'action=%s' % URL()}} URL() should generate the URL of the current action (though it won't include args and vars, so you'll have to add those explicitly if your URL happens to use them). However, I'm not sure it's necessary to have a non-empty action for valid HTML5 -- see #9 here: http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#form-submission-algorithm. An empty action appears to be valid. Anthony On Sunday, October 16, 2011 12:50:29 PM UTC-4, miroslavgojic wrote: I try next example and all mentioned options: def people(): form = crud.create(db.person,next=**URL('people'),message=T(**record created)) form['_action'] = URL('index') return dict(form = form) but my action field in form is empty. What do you mean the action field is empty? When I try the exact code above, I get the following in the resulting source html: form action=/testapp/default/index enctype=multipart/form-data method=post Are you expecting something else? - - Miroslav Gojic - - On Sun, Oct 16, 2011 at 16:09, Anthony aba...@gmail.com wrote: On Sunday, October 16, 2011 3:23:01 AM UTC-4, miroslavgojic wrote: I tray to put mentioned examples into controller after my form definition form['_action'] = URL(index') form.update(_action=URL('**index')) form.attributes.update(_**action=URL('index')) but it is not happened anything, What exactly happened? I assume this does change the form action as expected, but then nothing happens when you submit the form? When you change the form action, the form will get submitted to that action. If you submit the form to 'index', then your 'index' function will have to process the submitted form -- if there's no code in your 'index' function to do so, then nothing will happen. In web2py, forms are typically self-submitting (i.e., submitted to the action that generated them). Is there a reason you want to submit the form to a different action? and if I change my value I just get error form.update(_action=my_value) - this make error What is my_value? Is it a URL? In view after beginning of form.custom.start I tray next similar code {{=form['_action'] = URL(index')}} I assume you mean form.custom.begin? Anyway, it will not work to change the form action after that because form.custom.begin actually inserts the form tag with the action specified -- so changing the action after will not affect the way the form is serialized. Anthony
Re: [web2py] Re: Custom Form Action empty
On Sunday, October 16, 2011 4:54:34 PM UTC-4, miroslavgojic wrote: And about validation on suggested link it is writhed under point 9 (section 4.10.22.3) *If action is the empty string, let action be the document's address of the form document.* Yes, it's saying you can leave the action empty, and if you do, the browser will submit the form back to the URL of the current document, which is what we want (i.e., submitting back to the same action that generated the form). Anthony
Re: [web2py] Re: Custom Form Action empty
On Mon, Oct 17, 2011 at 03:16, Anthony abasta...@gmail.com wrote: On Sunday, October 16, 2011 4:54:34 PM UTC-4, miroslavgojic wrote: And about validation on suggested link it is writhed under point 9 (section 4.10.22.3) *If action is the empty string, let action be the document's address of the form document.* Yes, it's saying you can leave the action empty, and if you do, the browser will submit the form back to the URL of the current document, which is what we want (i.e., submitting back to the same action that generated the form). I see that, my form with action empty worked - that mean that action can be empty, but on www.http://validator.w3.org (validate by direct input) when I put my source I get error for empty action - when I put my site online this can be fixed by validating online page... - - Miroslav Gojic - - Anthony
[web2py] Re: Custom Form Action empty
After defining the form, try: form['_action'] = your_value # e.g., URL('controller', 'function', ...) You can also do form.update(_action=your_value) or form.attributes.update(_action=your_value). Basically, form is a helper object, _action is an attribute of the helper, and helpers behave like Python dictionaries with regard to their attributes (so the above are just regular dictionary methods). form.attributes is a dictionary storing just the attributes of the form, but you don't have to bother accessing it, as you can access the attributes directly from form. Anthony On Saturday, October 15, 2011 6:12:02 PM UTC-4, miroslavgojic wrote: in controller I have next line for form form = crud.create(db.name,next=URL('index'),message=T(some text)) in view I have {{=form.custom.begin}} {{=DIV(DIV('Name:', _id='two'),DIV(form.custom.widget.fieldname,_id='three'),DIV(form.custom.submit,_id='for'),_id='one')}} {{=form.custom.end}} this code produce form action= enctype=multipart/form-data method=post is is possible to put some value in action and how
Re: [web2py] Re: custom form trouble
Thanks for you answer, Anthony! Changed the code as you said and it worked! :D 2011/8/17 Anthony abasta...@gmail.com On Tuesday, August 16, 2011 11:35:40 PM UTC-4, Bruno Codeman wrote: Thanks for answering, Denes. I included manually the form/form tags because it wasn't been generated by web2py. I thought it very strange, but I'll try again tomorrow(It's 00:33AM in Brazil and I just got home, lol). Thanks for helping me again. You have {{form.custom.begin}}, but it should be {{=form.custom.begin}} (same for form.custom.end). Anthony -- Bruno de Oliva Bemfica *Engenheiro de Software* MSN: brunocode...@live.com bruno.bemf...@hotmail.com Mobile: +55 11 8457-0978 http://www.devfranca.com.br http://www.brunobemfica.net http://www.codigofree.net
[web2py] Re: custom form trouble
Probably need to see the relevant controller and view code.
[web2py] Re: custom form trouble
Hi Bruno, not sure if this is the problem but I believe you can not have nested forms. Your view has: {{form.custom.begin}} div class=wrapLogin form action= enctype=multipart/form-data method=post and /form /div div class=copyrightLogin© 2011, Groupon Inc. Todos os direitos reservados./div {{form.custom.end}} form.custom begin and end contain the opening form and closing / form tags, so you will have an invalid construct of a form inside another. Denes
Re: [web2py] Re: custom form trouble
Thanks for answering, Denes. I included manually the form/form tags because it wasn't been generated by web2py. I thought it very strange, but I'll try again tomorrow(It's 00:33AM in Brazil and I just got home, lol). Thanks for helping me again. 2011/8/16 DenesL denes1...@yahoo.ca Hi Bruno, not sure if this is the problem but I believe you can not have nested forms. Your view has: {{form.custom.begin}} div class=wrapLogin form action= enctype=multipart/form-data method=post and /form /div div class=copyrightLogin© 2011, Groupon Inc. Todos os direitos reservados./div {{form.custom.end}} form.custom begin and end contain the opening form and closing / form tags, so you will have an invalid construct of a form inside another. Denes -- Bruno de Oliva Bemfica *Engenheiro de Software* MSN: brunocode...@live.com bruno.bemf...@hotmail.com Mobile: +55 11 8457-0978 http://www.devfranca.com.br http://www.brunobemfica.net http://www.codigofree.net
Re: [web2py] Re: custom form trouble
On Tuesday, August 16, 2011 11:35:40 PM UTC-4, Bruno Codeman wrote: Thanks for answering, Denes. I included manually the form/form tags because it wasn't been generated by web2py. I thought it very strange, but I'll try again tomorrow(It's 00:33AM in Brazil and I just got home, lol). Thanks for helping me again. You have {{form.custom.begin}}, but it should be {{=form.custom.begin}} (same for form.custom.end). Anthony
[web2py] Re: custom form with validation
Maybe you could use an onvalidation function (see http://web2py.com/book/default/chapter/07#onvalidation). You might also consider adding the extra fields directly to the form object (see http://web2py.com/book/default/chapter/07#Adding-extra-form-elements-to-SQLFORM) instead of in the view, which may make it easier to add/display errors. Another option might be using SQLFORM.factory (see http://web2py.com/book/default/chapter/07#SQLFORM.factory) and creating a custom validator ( http://web2py.com/book/default/chapter/07#Custom-Validators). Anthony On Monday, June 6, 2011 11:55:36 AM UTC-4, David J wrote: I am trying to figure out how I can do validation on a custom form I have an order form; I need to set credit card expiration date as MM I have 2 fields 'expire_month' and 'expire_year' In my layout I manually added 2 select boxes; select name=expiry_month option value=01Jan/option ... /select select name=expiry_year option2011/option ... /select I need some idea how to validate this input to make sure it is not past the current date and obviously put the appropriate error message under the field like the rest of the errors being display. Any help would be appreciated. Thanks.
[web2py] Re: Custom form delete Crud checkbox
{{=form.custom.deletable}} it is not a widget. I agree that the name is not the most appropriate. On Feb 22, 4:07 pm, greenpoise danel.sega...@gmail.com wrote: I dont know where my posts are going...anyways, I have a Crud custom form. Its set but I am also customizing the layout of the crud update form and I cant seem to get the delete checkbox...how would I go for that?? {{=form.custom.widget.? tried: {{=form.custom.widget.delete/checkbox/delete_record/etcetcetc thanks d
[web2py] Re: custom form without using database?
See the Forms and Validators section of the book. You have total flexibility if you want to go to the trouble of building your own form. Check out the Custom Forms section of that chapter. On Feb 10, 12:45 pm, Panupat Chongstitwattana panup...@gmail.com wrote: What I meant was breaking the form down to pieces and put them at the appropriate places. Like, tr td 'Name :' comes here /td td INPUT _name comes here/td /tr tr td 'Password :'/td td INPUT _password /td etc. On Thu, Feb 10, 2011 at 7:37 PM, Bruno Rocha rochacbr...@gmail.com wrote: form = FORM() form.element().append(LABEL(_for='name',_value='Name')) form.element().append(INPUT(_type='text',_name='name')) print form form action= enctype=multipart/form-data method=postlabel for=name value=Name/labelinput name=name type=text //form --- Bruno Rocha http://about.me/rochacbruno/bio
[web2py] Re: custom form without using database?
Villas - I have read the book. The form.custom only works with SQLFORM and crud. I cannot use that same method with FORM. Looks like there are some other properties of the form I can output in the view... so far I found {{=form.formname}} - which just give me the word default {{=form[0]}} 1 2 3 4 to output each individual tags. The starting form tag and the hidden fields aren't stored this way tho. Anyone know what properties I can call to get the hidden fields? On Feb 10, 8:12 pm, villas villa...@gmail.com wrote: See the Forms and Validators section of the book. You have total flexibility if you want to go to the trouble of building your own form. Check out the Custom Forms section of that chapter. On Feb 10, 12:45 pm, Panupat Chongstitwattana panup...@gmail.com wrote: What I meant was breaking the form down to pieces and put them at the appropriate places. Like, tr td 'Name :' comes here /td td INPUT _name comes here/td /tr tr td 'Password :'/td td INPUT _password /td etc. On Thu, Feb 10, 2011 at 7:37 PM, Bruno Rocha rochacbr...@gmail.com wrote: form = FORM() form.element().append(LABEL(_for='name',_value='Name')) form.element().append(INPUT(_type='text',_name='name')) print form form action= enctype=multipart/form-data method=postlabel for=name value=Name/labelinput name=name type=text //form --- Bruno Rocha http://about.me/rochacbruno/bio
Re: [web2py] Re: custom form without using database?
I almost always use forms in this following way: *#Create a DIV to WRAP it all* div = DIV(FORM()) print div divform action= enctype=multipart/form-data method=post/form/div *#Take the elements of the wrapper using DOM* print div.element('form') form action= enctype=multipart/form-data method=post/form *#Create some other objects* table = TABLE() table.append(TR(TD(INPUT(_type='text',requires=IS_NOT_EMPTY() print table tabletrtdinput type=text //td/tr/table *#Append other objects to the wrapper* div.element('form').append(table) print div divform action= enctype=multipart/form-data method=posttabletrtdinput type=text //td/tr/table/form/div *#validators works well* div.element('form').element(_type='text')['requires'] gluon.validators.IS_NOT_EMPTY object at 0xa370f0c Note that it will work even if you want to use SQLFORM. -- Bruno Rocha http://about.me/rochacbruno/bio
[web2py] Re: custom form without using database?
Thanks Bruno. That looks very promising I'm trying it out now :) I got mine working too but it's very amature dir to find what's there and add bits and pieces of them into the view. /sigh. On Feb 10, 8:22 pm, Bruno Rocha rochacbr...@gmail.com wrote: I almost always use forms in this following way: *#Create a DIV to WRAP it all* div = DIV(FORM()) print div divform action= enctype=multipart/form-data method=post/form/div *#Take the elements of the wrapper using DOM* print div.element('form') form action= enctype=multipart/form-data method=post/form *#Create some other objects* table = TABLE() table.append(TR(TD(INPUT(_type='text',requires=IS_NOT_EMPTY() print table tabletrtdinput type=text //td/tr/table *#Append other objects to the wrapper* div.element('form').append(table) print div divform action= enctype=multipart/form-data method=posttabletrtdinput type=text //td/tr/table/form/div *#validators works well* div.element('form').element(_type='text')['requires'] gluon.validators.IS_NOT_EMPTY object at 0xa370f0c Note that it will work even if you want to use SQLFORM. -- Bruno Rochahttp://about.me/rochacbruno/bio
Re: [web2py] Re: custom form without using database?
Anyone know what properties I can call to get the hidden fields? Using SQLFORM you have form.hidden_fields() but using FORM you need to use Server side DOM and Parsing # *# Create a form with hidden elements* form = FORM(INPUT(_type='hidden',_value='secret'),INPUT(_type='hidden',_value='secret2')) print form form action= enctype=multipart/form-data method=postinput type=hidden value=secret /input type=hidden value=secret2 //form *#Get the hidden elements* form.elements(_type='hidden') [gluon.html.INPUT object at 0xa35920c, gluon.html.INPUT object at 0xa3592ec] *#Get by its index* form.elements(_type='hidden')[0] gluon.html.INPUT object at 0xa35920c *# each one* print form.elements(_type='hidden')[0] input type=hidden value=secret / print form.elements(_type='hidden')[1] input type=hidden value=secret2 / *#iterate* for element in form.elements(_type='hidden'): print element ... input type=hidden value=secret / input type=hidden value=secret2 /
[web2py] Re: custom form without using database?
What about widgets? IS_IN_DB() for example. Is there a way to get those working with a regular FORM without using SQLFORM? On Feb 10, 8:22 am, Bruno Rocha rochacbr...@gmail.com wrote: I almost always use forms in this following way: *#Create a DIV to WRAP it all* div = DIV(FORM()) print div divform action= enctype=multipart/form-data method=post/form/div *#Take the elements of the wrapper using DOM* print div.element('form') form action= enctype=multipart/form-data method=post/form *#Create some other objects* table = TABLE() table.append(TR(TD(INPUT(_type='text',requires=IS_NOT_EMPTY() print table tabletrtdinput type=text //td/tr/table *#Append other objects to the wrapper* div.element('form').append(table) print div divform action= enctype=multipart/form-data method=posttabletrtdinput type=text //td/tr/table/form/div *#validators works well* div.element('form').element(_type='text')['requires'] gluon.validators.IS_NOT_EMPTY object at 0xa370f0c Note that it will work even if you want to use SQLFORM. -- Bruno Rochahttp://about.me/rochacbruno/bio
Re: [web2py] Re: custom form without using database?
Thanks Bruno the DIV(FORM()) trick is really nice. Too bad there's no dd, dt, dl which is what I usually use for form layouts. I guess I can always manually append them in. On Thu, Feb 10, 2011 at 8:32 PM, Bruno Rocha rochacbr...@gmail.com wrote: Anyone know what properties I can call to get the hidden fields? Using SQLFORM you have form.hidden_fields() but using FORM you need to use Server side DOM and Parsing # # Create a form with hidden elements form = FORM(INPUT(_type='hidden',_value='secret'),INPUT(_type='hidden',_value='secret2')) print form form action= enctype=multipart/form-data method=postinput type=hidden value=secret /input type=hidden value=secret2 //form #Get the hidden elements form.elements(_type='hidden') [gluon.html.INPUT object at 0xa35920c, gluon.html.INPUT object at 0xa3592ec] #Get by its index form.elements(_type='hidden')[0] gluon.html.INPUT object at 0xa35920c # each one print form.elements(_type='hidden')[0] input type=hidden value=secret / print form.elements(_type='hidden')[1] input type=hidden value=secret2 / #iterate for element in form.elements(_type='hidden'): print element ... input type=hidden value=secret / input type=hidden value=secret2 /
Re: [web2py] Re: custom form without using database?
You can use TAG.dd() , TAG.dl() here is a working MVC example for a customized contact form, which sends an email http://pastebin.com/jTbGQNZk -- Bruno Rocha http://about.me/rochacbruno/bio
[web2py] Re: custom form without using database?
How do I add css class,id or java onClick etc to the tags? On Feb 10, 8:44 pm, Bruno Rocha rochacbr...@gmail.com wrote: You can use TAG.dd() , TAG.dl() here is a working MVC example for a customized contact form, which sends an email http://pastebin.com/jTbGQNZk -- Bruno Rochahttp://about.me/rochacbruno/bio
[web2py] Re: custom form without using database?
On Feb 10, 1:16 pm, Panupat panup...@gmail.com wrote: Villas - I have read the book. The form.custom only works with SQLFORM and crud. I cannot use that same method with FORM. Hi Panupat, I reread your original post again and I notice that your initial comment was: In the book only mentioned how to use custom form with pre-defined database. Your assumption in that comment does not seem correct because I make forms without any database tables by using SQLFORM.factory. Best wishes David
Re: [web2py] Re: custom form without using database?
Hi Villas I'm sorry, I see what you meant now. I wasn't aware of the factory feature before :) On Thu, Feb 10, 2011 at 11:52 PM, villas villa...@gmail.com wrote: On Feb 10, 1:16 pm, Panupat panup...@gmail.com wrote: Villas - I have read the book. The form.custom only works with SQLFORM and crud. I cannot use that same method with FORM. Hi Panupat, I reread your original post again and I notice that your initial comment was: In the book only mentioned how to use custom form with pre-defined database. Your assumption in that comment does not seem correct because I make forms without any database tables by using SQLFORM.factory. Best wishes David
[web2py] Re: custom form without using database?
Hi Panupat, No problem, web2py has so many useful features they are sometimes overlooked - especially by me! Anyhow I hope it will at least reduce some of the complexity for you :) -D On Feb 10, 5:11 pm, Panupat Chongstitwattana panup...@gmail.com wrote: Hi Villas I'm sorry, I see what you meant now. I wasn't aware of the factory feature before :) On Thu, Feb 10, 2011 at 11:52 PM, villas villa...@gmail.com wrote: On Feb 10, 1:16 pm, Panupat panup...@gmail.com wrote: Villas - I have read the book. The form.custom only works with SQLFORM and crud. I cannot use that same method with FORM. Hi Panupat, I reread your original post again and I notice that your initial comment was: In the book only mentioned how to use custom form with pre-defined database. Your assumption in that comment does not seem correct because I make forms without any database tables by using SQLFORM.factory. Best wishes David
[web2py] Re: custom form without using database?
Why do you use all the underscores? Is it because those variables are reserved words? Does it make the variables private or something?
Re: [web2py] Re: custom form without using database?
I use __ because I like to return locals() instead of a dict() Em 10/02/2011, às 18:53, pbreit pbreitenb...@gmail.com escreveu: Why do you use all the underscores? Is it because those variables are reserved words? Does it make the variables private or something?
[web2py] Re: Custom form bug
Hi, I can not reproduce this with 1.91.6, which version are you using?. On Jan 30, 8:16 pm, ionel ionelanton...@gmail.com wrote: I forgot to say that I use my own function to define the fields in the custom form. db.py: db.define_table('a_table', Field('field_name', 'text', length=600)) controller: def copyField(field): return Field(field.name, field.type, length=field.length) form = SQLFORM.factory(copyField(db.a_table.field_name)) i.a. On Jan 30, 7:45 pm, ionel ionelanton...@gmail.com wrote: Hello, With custom form I can do this form.table.field_name.length and I get the field length defined in model file, ex. Field('field_name', 'text', length=200) But for length 255, ex. Field('field_name', 'text', length=600), I get always 255 in form.table.field_name.length I use MySQL and I know that the max value for the data types CHAR and VARCHAR is 255, but for TEXT is 65535 characters. I think this is a bug. Thanks, i.a.
[web2py] Re: Custom form bug
Older version of mysql support maxlength=255 so that is what web2py does. I am not sure what the best solution wihtout using different adapters for different mysql versions. On Jan 30, 7:16 pm, ionel ionelanton...@gmail.com wrote: I forgot to say that I use my own function to define the fields in the custom form. db.py: db.define_table('a_table', Field('field_name', 'text', length=600)) controller: def copyField(field): return Field(field.name, field.type, length=field.length) form = SQLFORM.factory(copyField(db.a_table.field_name)) i.a. On Jan 30, 7:45 pm, ionel ionelanton...@gmail.com wrote: Hello, With custom form I can do this form.table.field_name.length and I get the field length defined in model file, ex. Field('field_name', 'text', length=200) But for length 255, ex. Field('field_name', 'text', length=600), I get always 255 in form.table.field_name.length I use MySQL and I know that the max value for the data types CHAR and VARCHAR is 255, but for TEXT is 65535 characters. I think this is a bug. Thanks, i.a.
[web2py] Re: Custom form bug
I forgot to say that I use my own function to define the fields in the custom form. db.py: db.define_table('a_table', Field('field_name', 'text', length=600)) controller: def copyField(field): return Field(field.name, field.type, length=field.length) form = SQLFORM.factory(copyField(db.a_table.field_name)) i.a. On Jan 30, 7:45 pm, ionel ionelanton...@gmail.com wrote: Hello, With custom form I can do this form.table.field_name.length and I get the field length defined in model file, ex. Field('field_name', 'text', length=200) But for length 255, ex. Field('field_name', 'text', length=600), I get always 255 in form.table.field_name.length I use MySQL and I know that the max value for the data types CHAR and VARCHAR is 255, but for TEXT is 65535 characters. I think this is a bug. Thanks, i.a.
[web2py] Re: Custom form
*I'll be more than happy, if I can go with a custom form.* *Only thing that I don't know in that case, is how to deal with upload field and make it into db.*
[web2py] Re: Custom form
please no more links in code. :-( On Dec 24, 11:19 am, Arun K.Rajeevan the1.a...@gmail.com wrote: Following are my tables. I need a form with an image upload (that's for table pictures), a disabled input with content (that's words.word) and a languages selection box(for word.lang). Upon form submission, I'll populate all other fields required for both tables. Is there a simple way to do this? If not, How to insert a picture manually.(with proper renaming etc., that's default) I'm running on GAE. db.define_table('languages', Field http://127.0.0.1:8000/examples/global/vars/Field('full', 'string', length=30, notnull=True, required=True), Field http://127.0.0.1:8000/examples/global/vars/Field('short', 'string', length=10 , notnull=True, required=True), Field http://127.0.0.1:8000/examples/global/vars/Field('natural', 'string', length=30), format='%(full)s - %(short)s') db.define_table('words', Field http://127.0.0.1:8000/examples/global/vars/Field('word', 'string', notnull=True, required=True), Field http://127.0.0.1:8000/examples/global/vars/Field('lang', db.languages, notnull=True, writable=False), Field http://127.0.0.1:8000/examples/global/vars/Field('entry_by', db.auth_user, notnull=True, readable=False, writable=False)) db.define_table('pictures', Field http://127.0.0.1:8000/examples/global/vars/Field('image', 'upload', notnull=True, required=True, label='Visual Lingua'), Field http://127.0.0.1:8000/examples/global/vars/Field('word', 'list:reference words', readable=False, writable=False, required=True), Field http://127.0.0.1:8000/examples/global/vars/Field('total', 'integer', readable=False, writable=False, default=2), Field http://127.0.0.1:8000/examples/global/vars/Field('clicks', 'integer', readable=False, writable=False, default=1), Field http://127.0.0.1:8000/examples/global/vars/Field('rating', 'double', readable=False, writable=False, compute=lambda row: row['total']/row['clicks']), Field http://127.0.0.1:8000/examples/global/vars/Field('entry_by', db.auth_user, notnull=True, readable=False, writable=False)) db.languages.full.requires = [IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY(), IS_NOT_IN_DB http://127.0.0.1:8000/examples/global/vars/IS_NOT_IN_DB(db, 'languages.full')] db.languages.short.requires = [IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY(), IS_NOT_IN_DB http://127.0.0.1:8000/examples/global/vars/IS_NOT_IN_DB(db, 'languages.short')] db.languages.natural.requires = [IS_NOT_IN_DB http://127.0.0.1:8000/examples/global/vars/IS_NOT_IN_DB(db, 'languages.natural')] db.words.word.requires = IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY() db.words.lang.requires = IS_IN_DB http://127.0.0.1:8000/examples/global/vars/IS_IN_DB(db, 'languages.id') db.words.entry_by.requires = [IS_IN_DB http://127.0.0.1:8000/examples/global/vars/IS_IN_DB(db, 'auth_user.id')] db.pictures.image.requires = [IS_NOT_EMPTY http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY(), IS_LENGTH http://127.0.0.1:8000/examples/global/vars/IS_LENGTH(262144, 4096), IS_IMAGE http://127.0.0.1:8000/examples/global/vars/IS_IMAGE(minsize=(60, 60))] #min_size 4kb, max_size 256kb; min_width 60px min_height 60px db.pictures.entry_by.requires = [IS_IN_DB http://127.0.0.1:8000/examples/global/vars/IS_IN_DB(db, 'auth_user.id')]
[web2py] Re: Custom form
Oh, How that happernd. I'm using new groups. It have advanced edit field. Hides links. For me it doesn't show links anyways, code without links follows. (*But, I'll be more than happy, if I can go with a custom form.* ** *Only thing that I don't know in that case, is how to deal with upload field and make it into db.)* db.define_table('languages', Field('full', 'string', length=30, notnull=True, required=True), Field('short', 'string', length=10 , notnull=True, required=True), Field('natural', 'string', length=30), format='%(full)s - %(short)s') db.define_table('words', Field('word', 'string', notnull=True, required=True), Field('lang', db.languages, notnull=True, writable=False), Field('entry_by', db.auth_user, notnull=True, readable=False, writable=False)) db.define_table('pictures', Field('image', 'upload', notnull=True, required=True, label='Visual Lingua'), Field('word', 'list:reference words', readable=False, writable=False, required=True), Field('total', 'integer', readable=False, writable=False, default=2), Field('clicks', 'integer', readable=False, writable=False, default=1), Field('rating', 'double', readable=False, writable=False, compute=lambda row: row['total']/row['clicks']), Field('entry_by', db.auth_user, notnull=True, readable=False, writable=False)) db.languages.full.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'languages.full')] db.languages.short.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'languages.short')] db.languages.natural.requires = [IS_NOT_IN_DB(db, 'languages.natural')] db.words.word.requires = IS_NOT_EMPTY() db.words.lang.requires = IS_IN_DB(db, 'languages.id') db.words.entry_by.requires = [IS_IN_DB(db, 'auth_user.id')] db.pictures.image.requires = [IS_NOT_EMPTY(), IS_LENGTH(262144, 4096), IS_IMAGE(minsize=(60, 60))] #min_size 4kb, max_size 256kb; min_width 60px min_height 60px db.pictures.entry_by.requires = [IS_IN_DB(db, 'auth_user.id')]