sulu icon indicating copy to clipboard operation
sulu copied to clipboard

Validation on page save validates also hidden tabs

Open datenwerk-at opened this issue 1 year ago • 1 comments

Q A
Sulu Version 2.5.10
PHP Version 8.2

Actual Behavior

A page had a page template "A". All required fields were filled in. Then the page became an internal link. Then new required fields were added to the page template "A". If I now try to change the page back to the "Content" page type and save it, I can't do that because the new required fields are not filled in. But I also have no way of doing that because I can't get to the "Details" tab until I've successfully saved the page under "Settings" tab.

Expected Behavior

Only the tab selected when saving should be validated (in this case "Settings").

Steps to Reproduce

see actual behavior

datenwerk-at avatar Jul 17 '24 12:07 datenwerk-at

For all others currently stumble over this issue there are currently two workarounds for it.

Workaround A: Create PHPCR Migration for the new property

After creating the new mandatory field. Create for that field also a PHPCR Migration (Documentation for PHPCR migration can be found here: https://docs.sulu.io/en/2.6/cookbook/migrate-content-data.html).

That migration should fillup the new field with a value, so also your twig template can handle it. That way the validation error should not longer be trigger on saving any tab.

Workaround B: Migrate Internal and External link pages to another template

After creating the new mandatory field. The templates do not have lot of effects for Internal and External links. So it is also possible to migrate all existing internal and external page template property (i18n-<locale>:template) to another phpcr template where not required fields exist. That way the validation error should not longer be trigger on saving any tab.


Some background the content tabs use all the same API Endpoint we do not registering for every tab an own resource and so resave all content even the one of the other Tabs in the current architecture. Adding required fields after pages are added will so endup in this kind of error sadly. A quickfix is currently in the core not easy possible as I see without a major refactoring or try and catches. But I think we can update the new Controllers of the new Page and Article Bundle to be here not be effected. At current case I recommend adding mandatory fields only with some kind of migrations, specially as you even require it if your twig template make them mandatory.

alexander-schranz avatar Jul 17 '24 12:07 alexander-schranz