Hi Massimo, thanks for your help, but the date and time widgets don't apear
since the input type is text:
>>> from py4web.utils.form import Form, FormStyleBulma
>>> from pydal import Field
>>> f=Form([Field('sdate','*date*')], formstyle=FormStyleBulma)
>>> print(f.xml())
<form method="POST" action="/" enctype="multipart/form-data"><div
class="field"><label for="none_sdate" class="label">Sdate</label><div
class="control"><input type="*text*" id="none_sdate" name="sdate"
class="input"/></div><p class="help"></p></div><div class="field"><div
class="control"><input type="submit" value="Submit"
class="button"/></div></div><input type="hidden" name="_formkey"
value="none"/></form>
Should be: ... <input type="*date*" ...
>>> f=Form([Field('stime','*time*')], formstyle=FormStyleBulma)
>>> print(f.xml())
<form method="POST" action="/" enctype="multipart/form-data"><div
class="field"><label for="none_stime" class="label">Stime</label><div
class="control"><input type="*text*" id="none_stime" name="stime"
class="input"/></div><p class="help"></p></div><div class="field"><div
class="control"><input type="submit" value="Submit"
class="button"/></div></div><input type="hidden" name="_formkey"
value="none"/></form>
Should be: ... <input type="*time*" ...
May need to fix py4web/utils/form.py ?
El miércoles, 1 de enero de 2020, 15:26:00 (UTC+1), Massimo Di Pierro
escribió:
>
> About the class style, you should specify it:
>
> >>> from py4web.utils.form import Form
> >>> from pydal import Field
>
> DEFAULT STYLE
>
> >>> f = Form([Field('a','text'), Field('b','string')])
> >>> print(f.xml())
> <form method="POST" action="/" enctype="multipart/form-data"><div
> class=""><label for="none_a" class="">A</label><div class=""><textarea
> id="none_a" name="a" class=""></textarea></div><p class=""></p></div><div
> class=""><label for="none_b" class="">B</label><div class=""><input
> type="text" id="none_b" name="b" class=""/></div><p class=""></p></div><div
> class=""><div class=""><input type="submit"
> value="Submit"/></div></div><input type="hidden" name="_formkey"
> value="none"/></form>
>
> BULMA STYLE
>
> >>> from py4web.utils.form import FormStyleBulma
> >>> f = Form([Field('a','text'), Field('b','string')],
> formstyle=FormStyleBulma)
> >>> print(f.xml())
> <form method="POST" action="/" enctype="multipart/form-data"><div
> class="field"><label for="none_a" class="label">A</label><div
> class="control"><textarea id="none_a" name="a"
> class="textarea"></textarea></div><p class="help"></p></div><div
> class="field"><label for="none_b" class="label">B</label><div
> class="control"><input type="text" id="none_b" name="b"
> class="input"/></div><p class="help"></p></div><div class="field"><div
> class="control"><input type="submit" value="Submit"
> class="button"/></div></div><input type="hidden" name="_formkey"
> value="none"/></form>
>
> On Monday, 30 December 2019 19:30:29 UTC+1, JSalvat wrote:
>>
>> Some testing done, I don't know the side efects, but with this changes
>> to py4web/utils/*form.py* things work munch better (as per
>> date/time/password widgets):
>>
>> ....
>> elif field.type == "text":
>> *# *control = TEXTAREA(value or "", _id=input_id, _name=
>> field.name) <--- MODIFIED
>> control = TEXTAREA(value or "", _id=input_id, _name=field.
>> name, _class="textarea")
>> ....
>> ....
>> else:
>> # field_type = "password" if field.type == "password" else
>> "text" <--- MODIFIED
>> field_type = "text" if (field.type == "string" or field.type
>> == "") else field.type
>> control = INPUT(
>> _type=field_type,
>> _id=input_id,
>> _name=field.name,
>> _value=value,
>> # _class=field_class, <--- MODIFIED
>> _class="input",
>> )
>>
>> # key = control.name.rstrip("/") <--- BLOCK 4 LINES UNUSED
>> # if key == "input":
>> # key += "[type=%s]" % (control["_type"] or "text")
>> # control["_class"] = classes.get(key, "")
>>
>>
>> Also, in Grid *create*: Boolean widget does not show selected state.
>> in Grid *modify*: If a field is modified and click on "Close"
>> instead of "Save", changes are saved !
>>
>> I'm using this table on Form / Grid tests:
>>
>> db.define_table(
>> 'sam_table',
>> Field('samString', type='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', type='text', comment='Enter a description text.'),
>> Field('samBool', type='boolean', default=False, comment='Are you
>> interested in py4web ?'),
>> Field('samDate', type='date', required=True,
>> requires = [IS_NOT_EMPTY(), IS_DATE()],
>> comment='Enter a valid sample date.'),
>> Field('samTime', type='time',
>> requires = IS_TIME(), comment='Enter a valid sample time.'),
>> Field('samInteger', type='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', type='decimal(4,2)', default=0.0,
>> requires = IS_DECIMAL_IN_RANGE(0, 35.0, dot=','),
>> comment='Enter a sample decimal between 0 and 35.'),
>> )
>>
>>
>>
--
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/03ea5649-5d87-42a8-ba20-5ba5e4124d3f%40googlegroups.com.