Form input for date does not start the calendar date picker

33 views
Skip to first unread message

Vlad

unread,
Aug 2, 2020, 8:48:34 PM8/2/20
to web...@googlegroups.com
Ok so I have this non-SQLFORM form

form = FORM(TABLE(TR(XML('Please enter/select below '),XML(' ')),
    TR(XML('Created'),INPUT(_name='skillcreated', _value=skillsdict['created']), _type="text",   ),
    TR(XML(' '),XML(' ')),
    TR(INPUT(_type='submit',_value="SUBMIT"),XML(' '))))

I have tried using 
type="date"
_type="date"
requires = IS_DATE(format=T('%Y-%m-%d'),

but in neither case I can get the calendar picker automatically added for the field.

Tried to search doc, examples, even the code in an auto-generated web2py form, to no avail.

All help will be appreciated 



Jim S

unread,
Aug 3, 2020, 12:16:45 AM8/3/20
to web...@googlegroups.com
What is the output you're hoping for?

It seems to me like you want to use SQLFORM.factory, you can read about it here:


form = SQLFORM.factory(Field('skill_created', 'date', requires=IS_DATE('%Y-%m-%d'), label='Created'))

Then in your view:

<div>Please enter/select below:</div>
{{=form}}


If that isn't what you want, can you post a sample table that you are trying to create?

-Jim

Clemens

unread,
Aug 3, 2020, 3:02:32 AM8/3/20
to web2py-users
Hi,

I'm using the datepicker in combination with an SQLFORM. Since the date is not used in any case I'm enhancing the SQLFORM named form as follows but exactly the way you want to do:
valid_thru = TR(TD(LABEL(T('Valid thru')), TD(INPUT(_name='valid_thru', _type='date', _value=datetime.now().strftime('%Y-%m-%d')))))
form[0].insert(-1, valid_thru)

And it works, with a preset value of today.


Hope it helps!

Best regards
Clemens
Reply all
Reply to author
Forward
0 new messages