syrusakbary / Flask-SuperAdmin

The best admin interface framework for Flask. With scaffolding for MongoEngine, Django and SQLAlchemy.
Other
641 stars 134 forks source link

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

Open jinzhangg opened 11 years ago

jinzhangg commented 11 years ago

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].

wojcikstefan commented 11 years ago

:+1:

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.

wojcikstefan commented 11 years ago

@jinzhang273 @SyrusAkbary I committed some code to https://github.com/SyrusAkbary/Flask-SuperAdmin/pull/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.

iurisilvio commented 11 years ago

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

jinzhangg commented 11 years ago

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

wojcikstefan commented 11 years ago

@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.