potiuk commented on a change in pull request #12837:
URL: https://github.com/apache/airflow/pull/12837#discussion_r537774829
##########
File path: airflow/www/forms.py
##########
@@ -230,14 +236,14 @@ class ConnectionForm(DynamicForm):
port = IntegerField(lazy_gettext('Port'), validators=[Optional()],
widget=BS3TextFieldWidget())
extra = TextAreaField(lazy_gettext('Extra'),
widget=BS3TextAreaFieldWidget())
- # You should add connection form fields in the hooks via
get_connection_form_widgets() method
- # See for example airflow/providers/jdbc/hooks/jdbc.py
- # It is esed to customized the form, the forms elements get rendered
- # and results are stored in the extra field as json. All of these
- # need to be prefixed with extra__ and then the conn_type ___ as in
- # extra__{conn_type}__name. You can also hide form elements and rename
- # others from the connection_form.js file
+ # Used to store a dictionary of field customizations used to dynamically
change available
+ # fields in ConnectionForm based on type of connection chosen
+ field_parameters = HiddenField(
+ lazy_gettext('field_parameters'),
default=json.dumps(_get_field_customizations())
+ )
Review comment:
I could not make it works (rendering scripts in submition forms
basically does not work), but I found a much better way. Instead of modifying
the Model, I modified the View and FormWidget. I learned a bit how FAB works
internally and it turned out that form widget is a better (and more natural)
way to pass the field behaviour.
That actually led me to a code where ConnectionForm does not have any
customizations, and all is done in the view part And it also let me to better
place where to initialze the providers and I am doing it now after plugin
initialization.
I decided to merge those two PRs, they make much more sense together than
separately.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]