xuganyu96 commented on code in PR #31141:
URL: https://github.com/apache/airflow/pull/31141#discussion_r1188889388


##########
airflow/www/widgets.py:
##########
@@ -40,6 +40,9 @@ class AirflowDateTimePickerWidget:
         "</div>"
     )
 
+    def __init__(self, input_required: bool = True):

Review Comment:
   Thank you for the feedback.
   
   > there can be multiple ways you can enforce an input field to be required
   
   Could you please clarify what other ways you are referring to? The only 
other place I can think of is with `wtforms` where the forms are validated, but 
I think these are separate layers of validation that should remain independent.
   
   ```python
   class PluginWebviewForm(FlaskForm):
       required_at_frontend = DateTimeWithTimezoneField(
           "Datetime required at frontend",
           widget=AirflowDateTimePickerWidget(),
       )
   
       required_at_backend = DateTimeWithTimezoneField(
           "Datetime required at form validation",
           widget=AirflowDateTimePickerWidget(),
           validators=[InputRequired()],
       )
   
       optional_datetime = DateTimeWithTimezoneField(
           "Datetime optional",
           widget=AirflowDateTimePickerWidget(input_required=False),
           validators=[Optional()],
       )
   ```
   
   What prompted me to make this change is the third field `optional_datetime` 
in the form where I want to collect an optional datetime.
   
   I did a quick search and found that `AirflowDateTimePicker` originally did 
not contain the "required" attribute at the input tag. Issue #15976 and pull 
request #18602 changed the widget so that the `required` attribute is always 
present, but I think that's too inflexible, and my change aims to make it more 
flexible.
   
   > if we can see in a single PR the change and its usage
   
   Is this comment sufficient, or should I produce documentation, as well?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to