You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are no similar issues or pull requests for this yet.
Is your feature related to a problem? Please describe.
In the list view for a model with relationships, I am able to override the ModelView.list_query property to customize the select query. This allows me to add filters to show results that are relevant. This functionality doesn't exist for the form view of a model.
Describe the solution you would like.
Adding an extendable ModelView.form_query would add another tool to solve the problems laid out in the documentation for relationship loading. Assuming that it's possible, the default function can remain the same as the existing query to populate a form, with users able to override that property in their own models if they need to.
Describe alternatives you considered
There is ModelView.form_ajax_refs, which allows a more restricted experience to ModelView.list_query. Where this breaks down for me is if I need to filter the select statement based on a property that isn't directly on the class described in the class. ModelView.form_ajax_refs allows me to specify fields on the given relationship. In the docs, the example is the street and zip_code fields on the address relationship. To extend the example, if the street property pointed to an object, and I wanted to filter this relationship based on a property of the street class, I would not be able to do so.
Additional context
There was a related issue that was raised in the past (now closed), where the user had created their own custom query within the update_model call. I think that the use case in this issue would have benefitted from a ModelView.form_query function to override as a more simplified solution.
There have also been two recent posts (here and here) in the Q&A discussion area about wanting to filter relationships in the form view.
The text was updated successfully, but these errors were encountered:
Checklist
Is your feature related to a problem? Please describe.
In the list view for a model with relationships, I am able to override the
ModelView.list_query
property to customize the select query. This allows me to add filters to show results that are relevant. This functionality doesn't exist for the form view of a model.Describe the solution you would like.
Adding an extendable
ModelView.form_query
would add another tool to solve the problems laid out in the documentation for relationship loading. Assuming that it's possible, the default function can remain the same as the existing query to populate a form, with users able to override that property in their own models if they need to.Describe alternatives you considered
There is
ModelView.form_ajax_refs
, which allows a more restricted experience toModelView.list_query
. Where this breaks down for me is if I need to filter the select statement based on a property that isn't directly on the class described in the class.ModelView.form_ajax_refs
allows me to specify fields on the given relationship. In the docs, the example is thestreet
andzip_code
fields on theaddress
relationship. To extend the example, if thestreet
property pointed to an object, and I wanted to filter this relationship based on a property of thestreet
class, I would not be able to do so.Additional context
There was a related issue that was raised in the past (now closed), where the user had created their own custom query within the
update_model
call. I think that the use case in this issue would have benefitted from aModelView.form_query
function to override as a more simplified solution.There have also been two recent posts (here and here) in the Q&A discussion area about wanting to filter relationships in the form view.
The text was updated successfully, but these errors were encountered: