stefanofontanelli/ColanderAlchemy

How to specify the order in which fields should be displayed ?

lei12 opened this issue · 9 comments

form.render() keeps returning fields in the initial order of the mapping, skipping the includes list order : is there a way to customize this ?

class Model(DeclarativeBase):
    __tablename__ = 'model_table'
    id = Column(...)
    col1 = Column(...)
    col2 = Column(...)
    col3 = Column(...)

schema = SQLAlchemySchemaNode(Model, includes=['col3','col2','col1'])

=> keeps displaying col1 then col2 then col3 fields

ooh.. this is a good point. Let me take a look.

@stefanofontanelli @davidjb are you guys okay with a change like this?

For sure - a patch/fix for this would be great. I'd hit this before but forgot about it since I took to just manually sorting the schema's children after constructing the schema.

Yes, I am OK. But I think it will affect all forms that are using CA. I
think a new parameter in the constructor it is better than using 'includes'
array so it makes possible to use current strategy when it isn't specified.

On Wed, Feb 5, 2014 at 3:34 PM, David Beitey notifications@github.comwrote:

For sure - a patch/fix for this would be great. I'd hit this before but
forgot about it since I took to just manually sorting the schema's children
after constructing the schema.

Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-34275435
.

Stefano Fontanelli
Senior Lead Engineer of Data & Infrastructure | Gild, Inc.
800-664-2366 | cell *+1-415-547-0722 (US), +39-333-365-3294* (IT)

465 California Street, Suite 1250
San Francisco, CA 94104
www.gild.com

The order before was a little odd as it would first do all columns and then all relationships. Now it's doing everything in proper order, so the order has already been changed from what it was doing before. includes already is specified as a list which implies some sort of order and I think most people would assume that order would be used over anything else.

It's a little disruptive to existing users, but I think the benefit outweighs the drawback.

Got the point. Go ahead :)

On Thu, Feb 6, 2014 at 11:12 AM, tisdall notifications@github.com wrote:

The order before was a little odd as it would first do all columns and
then all relationships. Now it's doing everything in proper order, so the
order has already been changed from what it was doing before. includesalready is specified as a list which implies some sort of order and I think
most people would assume that order would be used over anything else.

It's a little disruptive to existing users, but I think the benefit
outweighs the drawback.

Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-34358816
.

Stefano Fontanelli
Senior Lead Engineer of Data & Infrastructure | Gild, Inc.
800-664-2366 | cell *+1-415-547-0722 (US), +39-333-365-3294* (IT)

465 California Street, Suite 1250
San Francisco, CA 94104
www.gild.com

I am not sure to be skilled enough to do it all by myself...
Would someone mind helping ?

@lei12 - yeah, I was hoping to work on this "soon", but I've had a hard time finding the time. It's still on my TODO list, though.

A really poorly named PR was added that now allows you to control the order of schema element via the include argument. Sorry for the extremely long wait!