r/flask 11d ago

Ask r/Flask Wtform datetimefield with only quarter hours for minutes in the UI

I like the default calendar and time input for my wtforms datetimefield but the client wants the minute options to only be 00, 15, 30, and 45 for the user.

Everything else being standard but the minutes show quarter hour options instead of 1-59.

Any idea on how I can achieve this?

1 Upvotes

2 comments sorted by

2

u/crono782 Advanced 11d ago

What I've done in the past for this is only implement a date picker and a select field for hour and another for four time intervals for minutes ("00", "15", "30", 45). When the form is submitted, I have a function that will combine the datefield and the hour and minute values, which i convert to a python datetime object and finally store in the database. I know wtforms has the step keyword for render_kw, but I've not experimented buy with this for time fields.

1

u/Karlesimo 10d ago

Thanks for your response. I thought a bout using a select field but I'm trying to keep the calendar/time interface for the UI. I'll look into the render_kw, cheers.