[web2py] Re: Form fields in DB showing a 0 value

2013-11-11 Thread raferbop
Niphold, thanks for that info, but this is what I have;

db.define_table(
   'order_bus',
   Field('depart_from'),
   Field('arrive_to'),
   Field('date', 'date'),
   Field('time', db.depature_times), # drop-down select time options
   Field('no_of_passengers', db.tickets), # drop-down options to select 
number of positions
   Field('posted_on', 'datetime', readable=False, writable=False),
   Field('posted_by', readable=False, writable=False))

db.order_bus.depart_from.widget = SQLFORM.widgets.autocomplete(request, db.
route.city, id_field=db.route.id, limitby=(0,10), min_length=2)
db.order_bus.arrive_to.widget = SQLFORM.widgets.autocomplete(request, db.
route.city, id_field=db.route.id, limitby=(0,10), min_length=2)

I like to point out that something very strange happens;

When I select the depart_from and arrive_to fields, the auto complete 
options appear, and then I can choose a city. When the form is submitted, 
the route.id for the arrive_to field that was selected on the form, appears 
in the depart_from column in the order_bus db table. In addition to that, 
the arrive_to db table table shows 0. So I am not sure as what is really 
going on.


On Sunday, November 10, 2013 6:02:23 PM UTC-5, Niphlod wrote:
>
> after two days of bashing your head to the wall, why don't you read the 
> docs about the autocomplete widget ?
> You need to pass the id_field argument
>
>
> http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=autocomplete#Autocomplete-widget
>
> On Sunday, November 10, 2013 9:56:46 PM UTC+1, raferbop wrote:
>>
>> When I remove the auto complete widget, the data saves in the database is 
>> it should.
>>
>>

-- 
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: Form fields in DB showing a 0 value

2013-11-10 Thread Niphlod
after two days of bashing your head to the wall, why don't you read the 
docs about the autocomplete widget ?
You need to pass the id_field argument

http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=autocomplete#Autocomplete-widget

On Sunday, November 10, 2013 9:56:46 PM UTC+1, raferbop wrote:
>
> When I remove the auto complete widget, the data saves in the database is 
> it should.
>
>

-- 
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: Form fields in DB showing a 0 value

2013-11-10 Thread raferbop
When I remove the auto complete widget, the data saves in the database is 
it should.

On Saturday, November 9, 2013 7:34:39 PM UTC-5, 黄祥 wrote:
>
> oopss, sorry didn't notice that you are using 
> SQLFORM.widgets.autocomplete, yes, it should.
> basically the reference type of field is refer to primary key of the table 
> which is 'id' field, please use it as reference base and then please use 
> record representation (format) to show it in html form field.
> if you want to narrow down, please comment the autocoomplete widgets first 
> or if you are in development or testing environment please try to remove 
> the database first, sometime the migrations is not affected in database 
> table.
>
> p.s. : date field name in your order_bus table is a SQL/NOSQL keyword.
>
> best regards,
> stifan
>

-- 
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: Form fields in DB showing a 0 value

2013-11-09 Thread 黄祥
oopss, sorry didn't notice that you are using SQLFORM.widgets.autocomplete, 
yes, it should.
basically the reference type of field is refer to primary key of the table 
which is 'id' field, please use it as reference base and then please use 
record representation (format) to show it in html form field.
if you want to narrow down, please comment the autocoomplete widgets first 
or if you are in development or testing environment please try to remove 
the database first, sometime the migrations is not affected in database 
table.

p.s. : date field name in your order_bus table is a SQL/NOSQL keyword.

best regards,
stifan

-- 
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: Form fields in DB showing a 0 value

2013-11-09 Thread raferbop
Stifan,Winvalid literal for long() with base 10: 'Montego Bay'
On Saturday, November 9, 2013 4:03:15 PM UTC-5, 黄祥 wrote:
>
> please use format as record representation or set it on IS_IN_DB form 
> validation.
> e.g. if you want to show city as a drop down menu in order_bus form :
> db.define_table(
> 'route',
> Field('city'),
> Field('country_iso'), format = '%(city)s')
>
> db.order_bus.depart_from.requires = IS_IN_DB(db, 'route.id', '%(city)s', zero 
> = T('choose one'))
>
> db.order_bus.arrive_to.requires = IS_IN_DB(db, 'route.id', '%(city)s', zero 
> = T('choose one'))
>
> ref:
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Record-representation
>
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators
>
> best regards,
> stifan
>

-- 
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: Form fields in DB showing a 0 value

2013-11-09 Thread 黄祥
please use format as record representation or set it on IS_IN_DB form 
validation.
e.g. if you want to show city as a drop down menu in order_bus form :
db.define_table(
'route',
Field('city'),
Field('country_iso'), format = '%(city)s')

db.order_bus.depart_from.requires = IS_IN_DB(db, 'route.id', '%(city)s', zero 
= T('choose one'))

db.order_bus.arrive_to.requires = IS_IN_DB(db, 'route.id', '%(city)s', zero 
= T('choose one'))

ref:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Record-representation
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators

best regards,
stifan

-- 
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.