Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Nov 15, 2019 @ 14:22
    Ismail Mayat
    0

    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:

                        // 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?

    Unless there is another way?

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Nov 15, 2019 @ 15:41
    Anders Bjerner
    0

    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:

    image

    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.

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Nov 15, 2019 @ 16:42
    Dave Woestenborghs
    1

    Another option could be to swap the view to readonly or label when it's not a admin.

    Dave

  • Hasan Habib 8 posts 88 karma points
    Feb 20, 2023 @ 07:00
    Hasan Habib
    0

    Could you please share any example how to do it?

  • Paul Seal 524 posts 2889 karma points MVP 6x c-trib
    Nov 15, 2019 @ 17:13
    Paul Seal
    0

    That’s a good idea Dave You can edit the view in the sending content model event

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Nov 15, 2019 @ 17:17
    Ismail Mayat
    0

    Arrgh too late, I just created my own property editor based on dropdown one and added logic there. Anyhow good for next time.

Please Sign in or register to post replies

Write your reply to:

Draft