This project is read-only.

Throwing a message when Updating/Validating Part contents/data

Topics: Customizing Orchard, Writing modules
Sep 4, 2013 at 5:17 PM
Edited Sep 4, 2013 at 5:24 PM

When updating a Part, in the DriverResult Editor, how can we manually throw a warning message when implementing custom validation?

I want to add a custom validation for some date fields, where values are dependent on some other field in the Content Item itself (dates in the part need to be between a specific date in the content item's field).

Which leads me to another question, can we set validation in model properties between one another? Like if there are two properties StartDate and EndDate, is it doable in the model to declare that end date must be after start date?
Sep 5, 2013 at 1:39 AM
You can add model validation errors using the "updater" parameter being passed in:
updater.AddModelError("StartDate", T("Please enter a date in the future"));