plone / Products.CMFPlone

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

Schemaeditor in content types control panel and in easyform disables save / edit xml buttons semi randomly #3668

Open fredvd opened 2 years ago

fredvd commented 2 years ago

I'm seeing something really strange in the latest plone6.0b3 + collective.easyform 4.1.1. release. This uses plone.schemaeditor 4.0b2 . When you edit the field definitions, the bottom of the schema-editor form has 2 buttons to save or edit the schema-xml in text.

However, on every 2nd page load , the save and 'edit in xml' buttons get disabled after +/- 5 seconds.

I have the suspicion this might have been/is a feature to only enable the save button when something has been modified in the schema. But the xml editor button shouldn't be disabled, you can create new changes there. And it only happens on every second page load.

schemaeditor save edit xml

But it is not a collective.easyform bug. It also happens in the content types control panel. However the default content types have a filesystem/zope.schema definition and shouldn't be editable anyway.

Searching a bit more and I found this issue from last year where the buttons are indeed removed/disabled when there is a 'filesystem' schema already present: #3272 But it hasn't been closed yet and it seems to have a strange interaction

mauritsvanrees commented 1 year ago

I don't exactly see this. It might depend on what is in the schema.

I do see problems for collective.easyform due to validation. When you create a standard form and you go to 'Actions / Define form fields', you see a form where all three fields are required. When you don't fill them in, you will get a validation error, not from inline validation in Plone, but already from your browser. This may make the buttons inactive.

In plone.schemaeditor, when iterating over the widgets, we could set widget.required = False. This works, but then you do not have any indication of which fields are required. Not so nice when you are editing the schema.

To fix this, we might additionally set something like widget.secretly_required_anyway = True and then edit the widget template to show the <span class="required" so you still see the indication. Problem is that this means overriding more templates. These are templates that are used when rendering @@ploneform-render-widget. Easyform already overrides three of these widget templates. We would need to make these lines check our invented widget property.

But editing the three current custom widget templates does not help, as they is not active here, but only when a visitor actually uses the form. So it looks like we would need yet more overrides for plone.app.z3cform, with slightly different zcml registrations.

So it is the kind of exercise for which it helps if you enjoy having your head explode...

fredvd commented 1 year ago

I do see problems for collective.easyform due to validation. When you create a standard form and you go to 'Actions / Define form fields', you see a form where all three fields are required. When you don't fill them in, you will get a validation error, not from inline validation in Plone, but already from your browser. This may make the buttons inactive.

Chatted about this with @mauritsvanrees this morning. I checked this situation in Firefox by putting a breakpoint/event listener on the XML-editor button element in the DOM. It confirmed that pat-validation disables the button after a few seconds of the page being loaded, it is not the browser validation itself.