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

Add on_form_prefill hook to BaseModelView #607

Merged
merged 2 commits into from Jul 31, 2014

Conversation

jgonggrijp
Copy link

This is a solution for custom edit form fields that need to be pre-populated from the database in a way that Flask-Admin cannot figure out by itself. My personal use case is explained over here.

@mrjoes
Copy link
Member

mrjoes commented Jul 31, 2014

Good idea, but it won't work properly (or I didn't understand when it should be called).

If POST request is made to .edit_view and form validation fails, it'll still call the on_form_prefill. If you want to ensure that form should be populated only during initial load, add check request.method == 'GET'

@jgonggrijp
Copy link
Author

Thanks for pointing that out, I have done that.

mrjoes added a commit that referenced this pull request Jul 31, 2014
Add on_form_prefill hook to BaseModelView
@mrjoes mrjoes merged commit fe68e30 into flask-admin:master Jul 31, 2014
@jgonggrijp
Copy link
Author

Could you add me to the AUTHORS? Thanks in advance.

@mrjoes
Copy link
Member

mrjoes commented Aug 6, 2014

Sure, make another pull request.

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

Successfully merging this pull request may close these issues.

None yet

2 participants