Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

SQLFORM ... overridng a widget

25 views
Skip to first unread message

Dave S

unread,
Aug 10, 2024, 10:21:30 PM8/10/24
to web2py-users
I have a simple table (simplified more here) that has a date field:

db.define_table('QuarterMaster',
                Field('IssueYr', 'integer',
                     widget = lambda f, v: SQLFORM.widgets.integer.widget(f, v, _autofocus=True)),
                Field('PostDate', "date", requires=IS_DATE(format='%Y-%m-%d', error_message='must be YYYY-MM-DD!')))

The app I'm tweaking uses SQLITE3 as the DB, so under the blankets, the date is a string, but perhaps the blankets keep me from overriding the widget with this:

    form = SQLFORM(db.QuarterMaster, fields = ['PostDate'])
    db.QuarterMaster.PostDate.widget = SQLFORM.widgets.autocomplete(
        request, db.QuarterMaster.PostDate, id_field = db.QuarterMaster.id,
        min_length = 4, orderby = ~db.QuarterMaster.PostDate)

Am I out of luck, or just missing a little percursive maintenance to make the autocomplete fit?

/dps

Reply all
Reply to author
Forward
0 new messages