Better boolean toggle control for Flask-Admin inline form.
Replace this:
with this:
pip install flask-admin-toggle-control
Edit your view class to integrate toggle control:
Inherit from ViewMixin:
class SomeView(flask_admin_toggle_control.ViewMixin, ModelView): pass
Define fields to show with toggle control:
class SomeView(flask_admin_toggle_control.ViewMixin, ModelView): column_toggle_control_list = ["boolean_field1", "boolean_field2"]
Do not forget to have these fields editable:
class SomeView(flask_admin_toggle_control.ViewMixin, ModelView): column_toggle_control_list = ["boolean_field1", "boolean_field2"] column_editable_list = ["boolean_field1", "boolean_field2", "other_editable_field"]
Serve component JS file from static endpoint, pass your application object as a parameter:
app = Flask(__name__) flask_admin_toggle_control.init_static_ep(app)