Flask-AppBuilder icon indicating copy to clipboard operation
Flask-AppBuilder copied to clipboard

Adding items with related view CompactCRUDMixin shows relation columns which should be hidden

Open emilio-cartoni opened this issue 2 years ago • 1 comments

Environment

Flask-Appbuilder version: 4.1.1

Describe the expected results

I have an application where the model "Action" has a 1-N relationship to multiple "Movements". I am following the suggestion described here in the docs to have the related view of Movements extend both the CompactCRUDMixin and the ModelView class.

I would expect the related Movements view to be displayed on the same page of the Action view and to be able to add a Movement without having to specify which action it belongs to (since I am already on the page of the expected parent Action).

Describe the actual results

I do get the Movement view on the same page, and I can add the Movement without specifying the action. However, the action field is present in the form with a dropdown of the possible parent Actions. It does not matter which value I select there, the movement is always added to the parent Action displayed in the page (which is good).

However, the dropdown select field is confouding, since it can give the user the impression that he can assign the Movements he is adding to a different Action, which is not the case. Also, the default value of the dropdown is different from the current Action, so it gives the impression that the Movements might be added wrongly to another action.

I have tried many things (like using add_columns or add_exclude_columns) to exclude the Action dropdown selection, but to no avail. When I manage to exclude the dropdown selection (e.g. using add_exclude_columns), trying to add a Movement causes an error: no Movement is added to the database since no action id gets passed in the insert query.

I tried to debug a bit and I tound out that in the form.html template, no exclude_cols is passed, while it is correctly passed (and no action dropdown shown) when I remove the CompactCRUDMixin inheritance and the add Movement is done from a separate page.

emilio-cartoni avatar Jun 24 '22 16:06 emilio-cartoni

have all look at https://github.com/dpgaspar/Flask-AppBuilder/tree/master/examples/quickfiles

ThomasP0815 avatar Jun 27 '22 20:06 ThomasP0815