Contentful logo

Contentful Community

Conditional logic without re-building entire form


Question: Can conditional logic (for a group of fields) be implemented (via UI extension) without re-building the entire entry editor form?

Backstory: I’d like to add conditional logic to a specific Contentful content model. The logic would start from radio buttons, where the user would make a selection, and different form content would appear according to their selection. Something along the lines of:

<bunch of other fields>
<a selection field (e.g. radio button>
If selected A, show fields 1,3,4
If selected B, show fields 3,5,2
If selected C, show fields 6,1,4
<bunch of other fields>

From what I understand, a custom UI extension is needed to achieve this.

Works: I have a test entry editor extension working; there’s control over individual fields and functions successfully run when user interacts.

However, as far as I can tell, to keep the rest of the original form appear as-is, I have to re-build all of the fields (and logic) from scratch in my entry editor extension. Is this the case? Is there no way to avoid this?

My original content model (pre-ui extension) is already a long form with many text fields. I simply need conditional logic in one area half way down the page, and would rather not have to re-build the entire form (watering down the value of using Contentful in the first place).

I do see field-level ui extensions are possible, but other fields on the page are not accessible by a field-level extension. It would be nice if there were groupings in the Contentful content model builder, such that you can have a group of fields, and then have a UI extension just for that group. Have I missed something?

Hi @Fozzy, you are right, the correct way is to build your own entry extension, as field extension can’t control the display of other fields.

Another choice would be changing the content model. For example, in a ‘reference, many’ field, users can choose content type A, B, and C, and each content type has different fields.