agittr
agittr

Reputation: 75

Dexterity reorder inherited fields

How do i reorder fields that inherited from an existing behavior within a fields definition that i wrote my self. For example I want to use the leadimage field (behavior) from plone.app.contenttypes but instead of having it at the bottom of all fields i defined, i want to have it after the description.

I've tried like this:

<property name="model_source">
    &lt;model xmlns:security="http://namespaces.plone.org/supermodel/security" 
          xmlns:marshal="http://namespaces.plone.org/supermodel/marshal" 
          xmlns:form="http://namespaces.plone.org/supermodel/form" 
          xmlns="http://namespaces.plone.org/supermodel/schema"&gt;
    &lt;schema&gt;
      &lt;field name="image" type="plone.namedfile.field.NamedBlobImage" form:after="description"&gt;
          &lt;title&gt;Image&lt;/title&gt;
      &lt;/field&gt;
    &lt;/schema&gt;
    &lt;/model&gt;
</property>

and btw. is there a more readable way to do this?

Upvotes: 1

Views: 232

Answers (2)

agittr
agittr

Reputation: 75

form.order_after(image1='ILeadImage.image')

that did the trick, was a little confused within the code example...

followup question: if i have 3 image field with each having a caption field, do i really have to add that line to every field itself? or is there a way to set the order for all fields in one place like with the fieldset definition?

Upvotes: 2

hvelarde
hvelarde

Reputation: 2876

I never have tried this using XML but the Dexterity XML documentation says it's possible; check the after/before attributes.

I think you can have more control using Python code; check the Form schema hints documentation.

Upvotes: 1

Related Questions