plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
245 stars 188 forks source link

Add/Edit Forms broken, OrderedSelectWidget don't work with Plone 6.0.6 Classic UI #3817

Closed 1letter closed 1 year ago

1letter commented 1 year ago

What I did:

  1. install a fresh Plone 6.0.6
  2. Edit the Dexterity Item Document via http://localhost:8080/Plone/dexterity-types/Document/@@modeleditor
  3. add this schema
    <?xml version='1.0' encoding='utf8'?>
    <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns:marshal="http://namespaces.plone.org/supermodel/marshal" xmlns:form="http://namespaces.plone.org/supermodel/form" xmlns:security="http://namespaces.plone.org/supermodel/security" xmlns:indexer="http://namespaces.plone.org/supermodel/indexer" xmlns:lingua="http://namespaces.plone.org/supermodel/lingua" xmlns:users="http://namespaces.plone.org/supermodel/users" xmlns="http://namespaces.plone.org/supermodel/schema">
    <schema>
    <field name="day" type="zope.schema.Set">
      <form:widget type="z3c.form.browser.orderedselect.OrderedSelectWidget">
        <klass>annoying</klass>
      </form:widget>
      <default/>
      <description/>
      <title>day</title>
      <value_type type="zope.schema.Choice">
        <vocabulary>plone.app.vocabularies.Weekdays</vocabulary>
      </value_type>
    </field>
    </schema>
    </model>
  4. go to Portal Root and add a Document (set Title to 'Test'' and select a day) -> save the Page
  5. Edit the Page (change only the Title) -> Press Save

What I expect to happen:

The page could be saved

What actually happened:

The page could not be saved. Looks like validation error or an override in bootstrap event handling, but i'm not sure.

What version of Plone/ Addons I am using:

up to the version Plone 6.0.5 all is ok

Plone 6.0.6 is broken

petschki commented 1 year ago

This has to do with pat-validation because the values on the right selector field are not "selected" but its marked as "required" ... if you click them, then the browser validator lets you save. The in/out widget has to be refactored to fix the required issue for pat-validation

petschki commented 1 year ago

I took a closer look at plone.app.z3cform.templates.orderedselect_input.pt: the <select name="<fieldname>.to"> has the property required but the listed items are not select when you edit your page. This is not a problem because there are <input type="hidden" name="<fieldname>:list" value"xyz" /> which hold your saved value(s) so there's no data loss. But for validating required input it gets tricky... we could remove the required completely with the downside, that there's no browser validation for orderedselect widget ... server validation should work as usual.

1letter commented 1 year ago

@petschki i will upgrade the js ressource in z3c.form. "selected=selected" must explicit set on the options, right?

@petschki but in collective.taxonomy, the widget works. and this is not the same but similar to.

petschki commented 1 year ago

@1letter we can set this directly in plone.app.z3cform without touching z3c.form JS resources. BTW I never really liked this approach because the JS gets loaded multiple times if you have multiple OrderedSelectWidgets in a form. IMHO this should be refactored to a helper JS in plone.app.z3cform (like p.a.event does) or we write a pattern in mockup for this.

1letter commented 1 year ago

@petschki ok, thanks for the hint

1letter commented 1 year ago

closed via https://github.com/plone/plone.app.z3cform/pull/178