Hi there, I have created my own Media Type and created a field with the alias 'guid'.
I have also intercepted the Media_BeforeSave event in AppBase. In the code I'm creating a new guid and assigning it to the guid field. However, when the Media Type is re-displayed on screen, (having clicked save and triggered Media_BeforeSave), the Guid field in the Umbraco GUI is not populated with the latest value assigned by the code.
If I reload the Media Type, then all is well, because it's re-retrieving from storage.
So is there a way to persist data with a media type which the user/content editor does not have access to? Or is there a way to force umbraco to reload the Media Type after save?
The problem is that if someone clicks save twice, then we lose data...
It sounds like you need a custom data-type that will generate a Guid for you. That way you wouldn't need to hook into the event model (i.e. Media_BeforeSave).
Hi there, well it's OK, the hook into before save is for some other processing which works fine... actually in the end i used the Node's Unique ID, as this works perfectly - plus I didn't need to refresh the guid every time, so all is well.
Hide media type alias - or force reload
Hi there, I have created my own Media Type and created a field with the alias 'guid'.
I have also intercepted the Media_BeforeSave event in AppBase. In the code I'm creating a new guid and assigning it to the guid field. However, when the Media Type is re-displayed on screen, (having clicked save and triggered Media_BeforeSave), the Guid field in the Umbraco GUI is not populated with the latest value assigned by the code.
If I reload the Media Type, then all is well, because it's re-retrieving from storage.
So is there a way to persist data with a media type which the user/content editor does not have access to? Or is there a way to force umbraco to reload the Media Type after save?
The problem is that if someone clicks save twice, then we lose data...
thanks for your help
Kris
Hi Kristan,
It sounds like you need a custom data-type that will generate a Guid for you. That way you wouldn't need to hook into the event model (i.e. Media_BeforeSave).
Here's a couple of tutorials:
http://www.nibble.be/?p=24
http://www.nibble.be/?p=50
If you are having no joy with it, let us know... might be tempted to do a code snippet! ;-)
Cheers, Lee.
Found a better link... making use of the new AbstractDataEditor class:
http://www.nibble.be/?p=62
Hi there, well it's OK, the hook into before save is for some other processing which works fine... actually in the end i used the Node's Unique ID, as this works perfectly - plus I didn't need to refresh the guid every time, so all is well.
thanks again!!
k
is working on a reply...