Can you please check the latest version? This should be fixed.

translations in forms are not yet supported in an automatic manner. working 
on it.

On Tuesday, 24 December 2019 14:21:28 UTC+1, JSalvat wrote:
>
> Very simple Form and Grid sample to show some errors:
>
> In Grid: decimal field  does not show /  allow input.
>
> In Form: date and time widgets not working
>
> Mainly copied from examples, Showing what was modified:
>
> models.py
>
> import os
> from py4web import DAL, Field
> from pydal.validators import *
> # define database and tables
> db = DAL('sqlite://storage.db', 
> folder=os.path.join(os.path.dirname(__file__), 'databases'))
>
> # simple table example
> db.define_table(
>     'sam_table',
>     Field('samString', 'string', length=10,  unique=True, required=True,
>           requires = [IS_LENGTH(10, 4), IS_SLUG(maxlen=10,
>           check=True, error_message='Only alphanumeric characters and 
> non-repeated dashes.')],
>           comment='Unique identifier.'),
>     Field('samText', 'text', comment='Enter a description text.'),
>     Field('samBool', 'boolean', comment='Are you interested in py4web ?'),
>     Field('samDate', 'date', required=True,
>           requires = [IS_NOT_EMPTY(), IS_DATE()],
>           comment='Enter a valid sample date.'),
>     Field('samTime', 'time',
>           requires = IS_TIME(), comment='Enter a valid sample time.'),
>     Field('samInteger', 'integer', default=0,
>           requires = IS_INT_IN_RANGE(0, 9999, error_message='Must be 
> integer between 0 and 9999.'),
>           comment='Enter a valid sample integer.'),
>     Field('samDecimal', 'decimal(4,2)', default=0.0,
>           requires = IS_DECIMAL_IN_RANGE(0, 35.0, dot='.'),
>           comment='Enter a decimal between 0 and 35.'),
>     )
>
> if not db(db.sam_table).count():
>     db.sam_table.insert(
>         samString='2011',
>         samText='This record was inserted when first time create-table.',
>         samBool=True,
>         samDate='2011-12-24',
>         samTime='11:45:00',
>         samInteger=1234,
>         samDecimal=21.50)
>     db.commit()
>
> __init__.py
>
> import os
> from py4web import *
> from py4web.utils.form import Form, FormStyleBulma
> from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY
> from pydal.validators import *
> from . models import db
>
> session = Session(secret='mysecret')
>
> T = Translator(os.path.join(os.path.dirname(__file__), 'translations'))
>
> publisher = Publisher(db, policy=ALLOW_ALL_POLICY)
>
> @action('index')
> @action.uses('index.html')
> def index():
>     return {}
>
> # exposed as /sample/create_form or /sample/update_form/<id>
> @action('create_form', method=['GET','POST'])
> @action('update_form/<id>', method=['GET','POST'])
> @action.uses('form.html', db, session)
> def sample_form(id=None):
>     form = Form(db.sam_table, id, deletable=False, formstyle=
> FormStyleBulma)
>     rows = db(db.sam_table).select()
>     return dict(form=form, rows=rows)
>
> # exposed as /sample/grid
> @action('grid')
> @action.uses('grid.html')
> def sample_grid():
>     return dict(grid=publisher.grid(db.sam_table))
>
> form.html
>
> [[extend 'layout.html']]
>
> <h2 class="title">Sample Form</h2>
>
> [[=form]]
>
> <h2 class="title">Rows</h2>
>
> <ul>
>   [[for row in rows:]]
>   <li>[[=row.id]]: [[=row.samString]] ( [[=row.samBool]] )</li>
>   [[pass]]
> </ul>
>
>
> Have not tested translations yet.
>
>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/2bd7fc61-91de-4939-85f1-e75f0064bb86%40googlegroups.com.

Reply via email to