[web2py] Re: custom form web2py not work when i use selectpicker

2018-08-21 Thread Peng Wang
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

[web2py] Re: custom form web2py not work when i use selectpicker

2018-08-21 Thread Peng Wang
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.