Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ThomasP0815 opened this issue Jan 16, 2024 · 1 comment

Comments

@ThomasP0815
Copy link
Contributor

ThomasP0815 commented Jan 16, 2024

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:

  • provide get_pk_func method
   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 ThomasP0815 changed the title TypeError occured in front end when using the 'extra_classes=readonly' argument for the Select2Widget TypeError occured on front end when using the 'extra_classes=readonly' argument for the Select2Widget Jan 16, 2024
@ThomasP0815 ThomasP0815 changed the title TypeError occured on front end when using the 'extra_classes=readonly' argument for the Select2Widget TypeError occured on front-end when using the 'extra_classes=readonly' argument for the Select2Widget Jan 16, 2024
@ThomasP0815
Copy link
Contributor Author

fix #1467 does not work anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant