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?
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
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!
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
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
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
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
is working on a reply...