Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Francielle Castilhos 28 posts 150 karma points
    Jun 22, 2015 @ 16:23
    Francielle Castilhos
    0

    Validate property based in another property value

    Hi guys,

    I looked around and did not find an answer to my question.

    For example, I have a true/false property for a highlight on a document type. If the property is set to true, I need to make the image property mandatory. Is it possible to be done? If so, do you have any example on how to do this kind of validation?

    Thank you.

  • Luke 110 posts 256 karma points
    Jun 22, 2015 @ 18:11
    Luke
    0

    Hi Francielle,

    I would do this in the saving event.

    protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
     {
                Umbraco.Core.Services.ContentService.Saved += Content_Saved;
    }
    
        private void Content_Saved(Core.Services.IContentService sender, Core.Events.SaveEventArgs<Core.Models.IContent> e)
    

    Does this help??

    Regards, L

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Jun 22, 2015 @ 23:30
    Peter Gregory
    0

    Currently the only way is as Luke has mentioned by Luke is by doing the check in the Events and cancelling the event when the criteria doesn't match.

    You probably want to do your check on the publishing event. That way it will still save the document, and will allow the editor to save without causing validation errors until it actually matters.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Jun 23, 2015 @ 08:17
    Dave Woestenborghs
    1

    Another solution is to create a new property editor which contains the checkbox and the image property. Than you can do the validation clientside.

    Dave

  • Francielle Castilhos 28 posts 150 karma points
    Jun 23, 2015 @ 12:54
    Francielle Castilhos
    0

    Hi guys,

    Thanks for the replies. I'll test Luke's suggestion.

    Thank you!

Please Sign in or register to post replies

Write your reply to:

Draft