// mark this property as readonly so that it does not post any data
prop.Readonly = true;
Which would seem to imply readonly in this instance is not to make the property in backoffice readonly.
I also tried hiding the property for certain users which works. However if the user that does not have access publishes the node with property that property value will be set to empty.
So I am now thinking maybe i need to use angular interception then set the control to read only?
To follow up on my reply on Twitter (I was about to catch my train, so didn't read the thread here on Our fully).
It seems that you're already on to the SendingContentModel event. I believe this is the way to do, but on the other hand I'm not really sure how many property editors listen for this property.
If I try to set a property to readonly, it is reflected in the Angular model:
So the question may be whether the property editor actually supports being readonly. It could be considered a bug if it doesn't - even the ones native in Umbraco.
Make property read only
I am running v8 and I am trying to make one of my properties readonly for certain member types. I tried something based on https://github.com/janvanhelvoort/Umbraco-hide-properties/blob/develop/Source/Our.Umbraco.HideProperties/EventHandlers/EditorModelEventManagerEventHandler.cs and tried to set property to readonly. However its not readonly users can still update it. Looking into Umbraco code base we have:
Which would seem to imply readonly in this instance is not to make the property in backoffice readonly.
I also tried hiding the property for certain users which works. However if the user that does not have access publishes the node with property that property value will be set to empty.
So I am now thinking maybe i need to use angular interception then set the control to read only?
Unless there is another way?
Hi Ismail,
To follow up on my reply on Twitter (I was about to catch my train, so didn't read the thread here on Our fully).
It seems that you're already on to the
SendingContentModel
event. I believe this is the way to do, but on the other hand I'm not really sure how many property editors listen for this property.If I try to set a property to readonly, it is reflected in the Angular model:
So the question may be whether the property editor actually supports being readonly. It could be considered a bug if it doesn't - even the ones native in Umbraco.
Another option could be to swap the view to readonly or label when it's not a admin.
Dave
Could you please share any example how to do it?
That’s a good idea Dave You can edit the view in the sending content model event
Arrgh too late, I just created my own property editor based on dropdown one and added logic there. Anyhow good for next time.
is working on a reply...