I have a client that wants some functionality where the data is processed 'in the same order as the add/edit forms'. zope.schema.getFieldNamesInOrder apparently only gives the original order of fields as defined in the schema, and not after processing directives like order_before, order_after. As far as I can tell there is no utility function to get the actual order of the schema, behaviors and all?
This is a really hacky way that seems to work
class WebProjectSchema(AutoExtensibleForm, form.Form):
schema = IWebProject
class SomeOtherClass(BrowserView):
def get_field_names(self):
view = WebProjectSchema(context=self.context, request=self.request)
view.updateFields()
fields = [f for f in self.fields]
for group in self.groups:
fields.extend([f for f in group.fields])
return fields
I say hacky because it seems a bit silly to have to define that class and process the entirety of its fields just to get that order.
I guess it's a matter of perspective. I would think of the order defined in the schema as the "actual" order, and the order that takes the directives into account as a special feature provided by plone.autoform.
I say hacky because it seems a bit silly to have to define that class and process the entirety of its fields just to get that order.