PerplexDigital / Perplex.ContentBlocks

Block based content editor for Umbraco
MIT License
31 stars 15 forks source link

Issue with cultures in combination with a mandatory field #85

Closed TimmiX88 closed 7 months ago

TimmiX88 commented 7 months ago

We have a website with multiple cultures. When we add a contentblock with one or more mandatory fields to a page, we get a validationerror when saving the page.

Our setup is as following: Umbraco 13.2.2

Page: Documenttype Content with a Content Blocks Property. This property has the 'Allow Vary By Culture' checked.

Content Blocks We have a Documentype called 'CTA'. In this documentype we have the following fields

See screenshot: afbeelding

As you can see all fields have also 'allow vary by culture' checked

When we add this contentblock to a page even when we fill in all the fields correctly, we get the message that 'value can not be null'.

320475889-c2aaf210-50f0-4fcd-b50e-096d7558c15c

It seems like it expects items from another culture while we are currently on the Dutch culture. This only happens when 'person' is mandatory. If we make this field optional, we can save the page correctly. It seems like there is a conflict between culture variants and mandatory fields.

Is this a bug in ContentBlocks/Umbraco or is this a mistake in our configuration? Perhaps we should only allow vary by culture on the actual content documenttype and not on all the available contentblock items?

PerplexDaniel commented 7 months ago

Hi @TimmiX88,

The ContentBlock element types do not need Vary By Culture indeed, only the containing document type - "Content" in your case - needs to set Vary by Culture on the property used for ContentBlocks. This makes sense as on a Content page you vary the entire ContentBlocks property by culture, not necessarily on an individuel element level.

I wasn't aware that enabling Vary By Culture on the block element types leads to this behavior but regardless I would advice to test if this also occurs if Vary By Culture is off for the block element types. At Perplex we never enable Vary by Culture on content block element type level.

I just did a quick test and I can save a block with mandatory property without a problem on a content type that has 2 languages (EN/NL). This is in v13.2.0 (and ContentBlocks v3.0.0 if that matters, but likely the same behavior in 2.1.9).

image

TimmiX88 commented 7 months ago

@PerplexDaniel Thank you for the quick reply and explanation. You're right, it does make sense to not have culture variations on element level, just on the content page.

Perhaps good to add a little segment about this multi-culture setup to the documentation for clarification to prevent others from making the same mistake. ;)

TimmiX88 commented 7 months ago

We have changed our configuration to all our Content Blocks and done some tests and the problem seems to be fixed indeed. This ticket can be closed. Thanks again!

PerplexDaniel commented 7 months ago

Excellent, good to hear that resolves your issue 👍