dpgaspar / Flask-AppBuilder

Simple and rapid application development framework, built on top of Flask. includes detailed security, auto CRUD generation for your models, google charts and much more. Demo (login with guest/welcome) - http://flaskappbuilder.pythonanywhere.com/
BSD 3-Clause "New" or "Revised" License
4.63k stars 1.35k forks source link

TypeError occured on front-end when using the 'extra_classes=readonly' argument for the Select2Widget #2182

Open ThomasP0815 opened 7 months ago

ThomasP0815 commented 7 months ago

Environment

Flask-Appbuilder version: 4.3.10

pip freeze output:

apispec==6.4.0 attrs==23.2.0 Babel==2.14.0 click==8.1.7 colorama==0.4.6 Deprecated==1.2.14 dnspython==2.4.2 email-validator==1.3.1 Flask==2.2.5 Flask-AppBuilder==4.3.10 Flask-Babel==2.0.0 Flask-JWT-Extended==4.6.0 Flask-Limiter==3.5.0 Flask-Login==0.6.3 Flask-SQLAlchemy==2.5.1 flask-wtf==1.2.1 greenlet==3.0.3 idna==3.6 importlib-metadata==7.0.1 importlib-resources==6.1.1 itsdangerous==2.1.2 Jinja2==3.1.3 jsonschema==4.20.0 jsonschema-specifications==2023.12.1 limits==3.7.0 markdown-it-py==3.0.0 MarkupSafe==2.1.3 marshmallow==3.20.2 marshmallow-sqlalchemy==0.26.1 mdurl==0.1.2 ordered-set==4.1.0 packaging==23.2 prison==0.2.1 pygments==2.17.2 PyJWT==2.8.0 python-dateutil==2.8.2 pytz==2023.3.post1 PyYAML==6.0.1 referencing==0.32.1 rich==13.7.0 rpds-py==0.17.1 six==1.16.0 SQLAlchemy==1.4.51 SQLAlchemy-Utils==0.41.1 typing-extensions==4.9.0 werkzeug==2.3.8 wrapt==1.16.0 wtforms==3.1.2 zipp==3.17.0

Describe the expected results

Tell us what should happen.

Department field on the edit view for employees is readonly.

Describe the actual results

Tell us what happens instead.

Department field on the edit view for employees can be changed.

image

Steps to reproduce

Correct the example:

   class EmployeeView(ModelView):
        datamodel = SQLAInterface(Employee)

        list_columns = ["full_name", "department.name", "employee_number"]
        edit_form_extra_fields = {
            "department": QuerySelectField(
                "Department",
                query_func=department_query,
                get_pk_func=lambda obj: obj.id,
                widget=Select2Widget(extra_classes="readonly"),
            )
        }

        related_views = [EmployeeHistoryView]
        show_template = "appbuilder/general/model/show_cascade.html"

Run the employees application from the examples in the flask-appbuilder repo. Create a function. Create a benefit. Create a department. Create a employee. Open the edit view for the employees in the web browser. Start the developer tools (F12).

ThomasP0815 commented 7 months ago

fix #1467 does not work anymore