ckrall
ckrall

Reputation: 77

Reordering Fields on Extended Content Type

I have extended a basic Plone content type using archetypes.schemaextender. I need to reorder the fields on the edit page. When I do, the reordered fields appear in a new tab called "content" on the edit interface. How can I get the fields to appear in the "default" tab of the edit interface instead?

Here is the code snippet from my extender.py:

class extenddocument(object):
    adapts(IATDocument)
    implements(IOrderableSchemaExtender, IBrowserLayerAwareExtender)

    layer = IextenddocumentLayer

    fields = [
        _ExtensionStringField(
            name='longTitle',
            widget=StringWidget(
                label=u'Long Title',
                description=u'Optional descriptive title to replace default title as the page heading',
                size='50',
            ),
            required=False,
            searchable=True,
        ),
    ]

    def __init__(self, context):
        self.context = context

    def getOrder(self, schematas):
            """ Manipulate the order in which fields appear.
                @param schematas: Dictonary of schemata name -> field lists
                @return: Dictionary of reordered field lists per schemata.
            """
            schematas["Content"] = ['title', 'longTitle', 'description', 'text']
            return schematas

    def getFields(self):
        return self.fields

attached is the edit tab view: enter image description here

Upvotes: 0

Views: 154

Answers (2)

Ida
Ida

Reputation: 3965

Or, as you actually don't need an extra-fieldset, because and added field will be appended to the default-fieldset anyway, you could also just reorder your field – instead of the whole fieldset – as described here:

http://developer.plone.org/content/archetypes/fields.html#reordering-fields

Here is a nice documentation of Inqbus, which gives you an overview of the possibilities of reordering fields and fielsets, it's in German, but the code-parts are self-explaining:

http://inqbus-hosting.de/support/dokumentation/docs/plone-archetypes-schemata-und-fields

Upvotes: 1

David Glick
David Glick

Reputation: 5432

In the getOrder method, assign your list of fields to schematas['default'] instead of to schematas['Content'].

Upvotes: 3

Related Questions