Às 00:39 de 17-08-2018, 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()defstudents(): form
> =form=SQLFORM.factory(db.person,db.address) ifform.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!' elifform.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
>
> |
> <formaction="#"class="form-material"enctype="multipart/form-data"method="post">
>
> <divclass="form-group"> <divclass="col-md-12 m-b-20">
> <!--form.custom.widget.name -->
> <inputclass="form-control"id="no_table_name"name="name"type="text"placeholder="nome">
>
> </div> <divclass="col-md-12 m-b-20">
> <!--form.custom.widget.cpf -->
> <inputclass="form-control"id="no_table_cpf"name="cpf"type="text"placeholder="cpf">
>
> </div> <divclass="col-md-12 m-b-20">
> <!--form.custom.widget.email -->
> <inputclass="form-control"id="no_table_email"name="email"type="text"placeholder="email">
>
> </div>
> <divclass="col-md-12 m-b-20"> <!--
> <select class="form-control generic-widget" id="no_table_address_type"
> name="address_type"><option value="">Vazio</option><option
> value="1">Comercial</option><option value="2">Residencial</option></select>
> --> <selectclass="form-control
> selectpicker"
> id="no_table_address_type"name="address_type"data-style="btn-info
> btn-outline-info">
> {{for t in address_type_list:}}
> <optionvalue="{{=t.id}}">{{=t.type}}</option>
> {{pass}} </select> </div>
> <divclass="col-md-12 m-b-20">
> <selectid="no_table_cities"name="cities"data-style="btn-info
> btn-outline-info"required> {{for city in cities_list:}}
> <optionvalue="{{=city.id}}">{{=city.name}}</option>
> {{pass}} </select> </div>
> <!--form.custom.end --> <divclass="hidden">
> {{=form.hidden_fields()}} </div> </div>
> <divclass="modal-footer"> <inputclass="btn
> btn-info"type="submit"value="Salvar">
> <buttontype="button"class="btn btn-default
> waves-effect"data-dismiss="modal">Cancelar</button> </div>
> </div></form>
> |
>
>
>
> 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
>
> <Storage {'name': 'maria', 'cpf': '09102910', 'birthday': None, 'email':
> '[email protected]', '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 [email protected]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout.
Hi,
I just add this piece of javascript at the end of layout.html to add the
selectpicker class to select elements:
jQuery(function(){ jQuery( 'select' ).selectpicker();
jQuery('.selectpicker').selectpicker('refresh'); } );
This adds the 'select_picker' class to everey select statement.
Regards,
Carlos Correia
=========================
MEMÓRIA PERSISTENTE
GSM: 917 157 146
e-mail: [email protected]
URL: http://www.memoriapersistente.pt
XMPP (Jabber): [email protected] (NOVO)
GnuPG: wwwkeys.eu.pgp.net
URL Suporte: https://t5.m16e.com/gps
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.