syrusakbary / Flask-SuperAdmin

The best admin interface framework for Flask. With scaffolding for MongoEngine, Django and SQLAlchemy.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow form field order to be set by user in Edit View

jinzhangg opened this issue · comments

I couldn't find this looking through the source or documentation but is it possible to customize the order of the form fields in the Edit view in Flask-Superadmin?

So right now, in the Edit View, the form fields are in random order and I would like to organize it a bit so they make logical sense.

For example, instead of it showing a possible address form in the order [city, address, zipcode], I would like to organize it to [address, city, zipcode].

👍

I'm not sure, if it's possible right now. Gotta dig into it a little more. Will submit a PR if it's indeed not possible at the moment.

@jinzhang273 @syrusakbary I committed some code to #58. I only tested it for MongoEngine and it's definitely not yet working for Django, nor SQLAlchemy. Will try to solve it for the other backends soon, unless any of you takes over before that happens.

Also, it's probably about time to introduce some serious unit tests.

👍 to unit tests. Tests should run the same way to each backend, changing the minimum code as possible.

@wojcikstefan Thank you for adding this! I just got a chance to test this and it is working great for me.

@jinzhangg glad you like it. Just an FYI - I'm planning to get rid of the only keyword and make the model admin more Django-ish, i.e. only use fields, readonly_fields and exclude. You'll specify the order in fields and will be able to include some extra info through readonly_fields (will first look for methods on the model admin, then on the model's methods/fields). Something to keep in mind, in case you'll upgrade after (or if) my changes get merged.