[plone.autoform] order_before()/order_after() not working as expected

I have this schema behavior which is supposed to place the test_field as first field in the edit form (working) and a boolean field show_description after the description field (not working).

Anything missing here?

@provider(IFormFieldProvider)
class ITestSchema(model.Schema):

    form.order_before(test_field='*')
    test_field = zope.schema.TextLine(
            title=u'Test field',
            description=u'test field',
            default=u'Foo Bar')

    form.order_after(show_description='IBasic.description')
    show_description = zope.schema.Bool(
            title=u'Show description',
            description=u'Show description')

Solved. The documentation

https://docs.plone.org/external/plone.app.dexterity/docs/grok/reference/form-schema-hints.html

is wrong. It must be IDublinCore.description and everything works as expected.

The easiest could be to just check the field names in the dexterity control panel (especially for behavior added fields, I would think):

like, http:/mysite/dexterity-types/Document/@@fields

Depends on the behavior used. IDublincore is a compound. If it is used you need to reference it. If you use IBasic, then this.
IMO the whole IDublincore compound was a big mistake. But well, here we are...:wink:

Guess I am misunderstanding something here:
I thought every field with name like 'From xxx behaviour yyy' would referenced to as xxx.yyy

(so from the screenshot, I though it also would be IRichTextBehavior.text … is that wrong ? )

IDublincore is a subclass inheriting IBasic and more. So, it depends on if your type uses the compound or the single base classes.

This observation is absolutely correct.

So I ended up using an Excel sheet for documentation the current state of our behaviors and the final state...Excel-driven development with Plone^^

The naming schema is in particular stupid when you need to redefine the IDublinCore with ÌMyDublinCore`.

So in the original behavior we move the show_description field after IDublinCore.description and with the new behavior we have to move for a different usecase after IMyDublinCore.description...it is hard to maintain and understand this nonsense... #sigh

Indeed, I really think the compound IDublinCore at all was a mistake. Keeping them separate behaviors would make it so much simpler. If a single field would have its distinct namespace it would help too, like plone.basic:description but I am not the one implementing this for free (insert coin).

I did not get all implementation aspects but it would make sense define everything single field (its interface and class implementation) by itself and then provide some easy functionality for building compounds. Building compounds from single fields is much easier than breaking a compound into pieces for the sake or reusability or customization.

2 Likes