3

We want to disable specific Form elements in Sitecore Forms for all users that aren't administrators.

I tried to do so by setting the read permission to deny on the field type (under /sitecore/system/Settings/Forms/Field Types) for the sitecore/Everyone role.

This hides the Form element from the design panel and the form itself in the forms editor, but if the user saves a form that has the element, the element gets removed.

Is there a way to just hide it from the design panel, so users cannot add it?
The editing is already disabled by setting the field write permission on the template field to deny.

0

1 Answer 1

2

I contacted the Sitecore Support who say that there is no official way to do this by now.

So we solved it manually:

  • Overwrite/replace the AccountInformation bar at the top and add the information if a user is admin
    • Core Database: /sitecore/client/Business Component Library/version 2/Layouts/Renderings/Authentications/AccountInformation
    • The cshtml file is virtual and can be found in Sitecore.Speak.Components.Web.dll
    • When using a different path for your new cshtml, you need to have a copy of the JS file found here: \sitecore\shell\client\Business Component Library\version 2\Layouts\Renderings\Authentications\AccountInformations, and name it like your cshtml
  • Hide the form element in the design panel by using CSS (display:none)
  • Show the form element in the design panel by checking the admin information in the top bar with JS and setting display:flex
    • CSS and JS can be found here: \sitecore\shell\client\Applications\FormsBuilder\Pages\FormDesigner

Of course this does not prevent sneaky editors from adding it to the page, but as they cannot edit it (deny rights on the template fields), it's ok for us.

1
  • Bro this is awesome, thanks
    – Bgl86
    Feb 10, 2022 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.