Copied to clipboard

Flag this post as spam?

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


  • Vicente 2 posts 22 karma points
    Apr 04, 2013 @ 14:44
    Vicente
    0

    Data type validator

    Hi!

    My questions maybe are easy to answer   but I haven't been able to find the solutions so far.

    1. I'm trying to include a file name validator for Media Picker. Currently I added a regex expression to validate the file name but the validator isn't fired.

    2. I'd like to validate a text field which must be unique between nodes. I don't have a clear approach to do it, could anyone help me with it?

     

    Thanks!

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Apr 04, 2013 @ 23:23
    Jan Skovgaard
    0

    Hi Vicente and welcome to our :)

    Are you trying to expand the fucntionality of Umbraco using your own datatype? Or do I misunderstand?

    You should be able to simply define some regex when you define the properties of your document type.

    Btw what version of Umbraco are you using?

    /Jan

  • Vicente 2 posts 22 karma points
    Apr 08, 2013 @ 10:25
    Vicente
    0

    Sorry, I was in a rush on Thursday and I didn't give all the information I should.

    Jan, I'm using the Media Picker, not a custom control. I tried using some regex but any of them was use it.

     

    About my second question. I'm using a umbracoUrlAlias and I'd like to check that is unique between the pages. Is it possible?

    I'm using Umbraco 4.7.2

     

     

  • Asif Malik 203 posts 339 karma points
    Apr 08, 2013 @ 16:57
    Asif Malik
    0

    Hi Vicente, not really sure you can do the first item because when you save the page the media picker only stores the ID of the associated media item.

    What i would look to do is create an extension which fires when you click publish (or save), you would need to create a class that inherits from IApplicationEventHandler and then in the inherited methods you can do something like

            public void OnApplicationStarting(UmbracoApplication httpApplication, ApplicationContext applicationContext)
            {
                Document.AfterSave += Document_AfterSave;
            }

    where the Document_AfterSave mehtod is your own code which does the checking, take a look at

    http://our.umbraco.org/wiki/reference/api-cheatsheet/using-iapplicationeventhandler-to-register-events

    hope that helps

Please Sign in or register to post replies

Write your reply to:

Draft