Hello,
I really have a lot of difficulty redefining the validation schema of a field in an exiting form.
The idea is to define a required field according to the choice of a drop-down list. I am using an extension app with a DropdownEditor (field-editor) for DropDownList and I get the value I choose from sdk.field.onValueChanged
For example: If I choose ‘Accepted’ in the drop-down list the StartDate field must be required and I click on Publish, I would like to have a publication error and the error below the StartDate field
1st try (not working):
sdk.entry.fields.startDate.required = true;
2nd try (not working):
const startDate = sdk.contentType.fields.find((f) => f.id === ‘startDate’);
startDate.required = true;
sdk.contentType.fields = sdk.contentType.fields.map ((m) => (m.id! == startDate.id? m: startDate));
3rd try (error VesrionMisMatch):
const startDate = sdk.contentType.fields.find((f) => f.id === ‘startDate’);
startDate.required = true;
sdk.contentType.fields = sdk.contentType.fields.map ((m) => (m.id! == startDate.id? m: startDate));
updateContentType (sdk.contentType);
4th try (success 200 but not working after click publish button):
async function updateContentType (contentTypeUpdate: any) {
// Update content type
customer
.getSpace (‘space_id’)
.then ((space) => space.getEnvironment (‘env-id’))
.then ((environment) => environment.getContentType (contentTypeId))
.then ((contentType) => {
contentType.fields = contentTypeUpdate.fields;
return contentType.update ();
})
.then ((contentType) => console.log (Content type $ {contentType.sys.id} renamed.
))
.catch (console.error);
}
const startDate = sdk.contentType.fields.find((f) => f.id === ‘startDate’);
startDate.required = true;
sdk.contentType.fields = sdk.contentType.fields.map ((m) => (m.id! == startDate.id? m: startDate));
updateContentType (sdk.contentType);
Could you help me please ?