Link field validation from parent

Imagine a model where there is a parent content type § and a child content type ©. Now when adding children in the parent I need to validate that children meet the requirements (e.g. a < 5 && b > 6) and display which children are invalid.

// Model
C {a: 1,b: 2}
P {arrayOfLinks: [C1, C2, C3], validationOfLinks: false}

When simply adding and removing children this validation works fine as I can listen for field.onValueChange

But now when a user has selected the children and goes within one child and changes the value(s) I don’t have any events to trigger the validation.

Is there an beforePublish event or some other way to monitor values within children from a ui-extension?

Publishing validations only apply to the content of the current entry itself. If you create a link from a parent entry, P, to a child entry, C, all that exists in P is a link that says “this is a link to entry C”. If you then go directly to entry C and change something, there is no mechanism that entry P will know anything has changed. The link to entry C is still there.

It will be better to have the validations exist on the child content type that prevent publishing if field a >= 5 && field b <= 6.

Can you give a more concrete example of what you are talking about?

Hi it’s more like a user aid rather than something to prevent publishing.

The actual use case is to manage campaigns with a start and expiry date. So the children have a start/end date and the parent has a list of campaigns. Since children are more or less static entries (created and forgotten) we’d like to show the user which campaigns are currently active in the parent view. So that they could update or archive the expired ones.

Main problem is that currently when the entry is opened we query all of the links and do the validation, but if they go and update any of the links we don’t have any events to act upon for re-validation.

You can make a custom UI extension which would live on the Campaigns List field of the parent. That extension could then look at each child campaign and show the start and end dates and if the campaign is not active you could style it a certain way.

Yes that’s the idea and that is what we had before. But now with the Contentful UI changes we found a problem.

  1. User selects all the campaigns
  2. Validation is done in the campaign list and styled in an appropriate way
  3. User goes to one of the campaigns and makes the date invalid
  4. User returns to campaign list and the validation is not updated (because there are no events to act upon)

In the previous version of the UI user had to navigate away from the page and that’s what made it work, but currently pages are stack upon each other and parent is never re-initiated. Previously we had the same problem using multiple tabs.

Hmm interesting. That should be something that can be done. I will send a note the the product team in charge of that feature about this and see what they suggest as the best way to handle it.