1

I'm using wtforms in python, and everything is working fine, but I want to round the TimeFiled to hour only and keep the minutes in 00. For example 14:00, 15:00, so the user can choose only hour, not minutes.


My forms.py:

    class DateForm(FlaskForm):
        name = StringField("Nombre", validators=[DataRequired()])
        email = StringField("Email", validators=[DataRequired()])
        date = DateField("Fecha", validators=([InputRequired(), DataRequired()]))
        hour = TimeField("Hora", validators=([InputRequired(), DataRequired()]))
        submit = SubmitField("Agendar cita")

my appointment.html:

     {{ form.csrf_token() }}
     {{ wtf.quick_form(form, novalidate=True, button_map={"submit": "primary"}) }}
      {% with messages = get_flashed_messages() %}
      {% if messages %}
        {% for message in messages %}
         <p style="color:red">{{ message }}</p>
        {% endfor %}
      {% endif %}
    {% endwith %}

This is how it looks like now: enter image description here How can I accomplish this?

Progman
  • 16,827
  • 6
  • 33
  • 48
PabloM
  • 29
  • 6

1 Answers1

0

At the moment I could find a workaround by adding within a function a validation:

elif form.hour.data.minute != 0: "raise a message".

but I think it would be nice and better to show the user only 00 minutes for each hour.

PabloM
  • 29
  • 6