You can use custom values for the ReadOnlyModes and HiddenModes properties, which get evaluated whenever the form gets rendered, regardless of its mode. To do this, Sitefinity CMS implements IFormEntryEditModeProvider interface in a class.
The interface requires the implementation of method GetCurrentMode.
The method returns a string that represents the value used for the HiddenModes and the ReadOnlyModes properties of the form's widgets.
This method gets invoked whenever the form gets rendered and can evaluate custom conditions, for example, check the currently logged-in user. The returned value is compared to the field's properties' values. If the returned value matches the value of the field's HiddenModes property, the field is hidden. Similarly, if the returned value matches the value of the field's ReadOnlyModes property, the field is rendered as read-only
This means that to set the field as read-only when editing a form's response, the value of the ReadOnlyModes property of the respective form widget must be set to a string equal to the one returned by the GetReadOnlyMode method.
Similarly, to hide a field when editing a form's response, the value of the HiddenModes of the respective form widget must be set to a string equal to the one returned by the GetHiddenMode method.
The following example demonstrates the implementation of the IFormEntryEditModeProvider interface where the returned value depends on the role of the currently logged user.
Whenever the form is rendered, the method is invoked.
Use the following code:
To invoke the method, you must register the class implemented above in the Global.asax, using Sitefinity's ObjectFactory:
Back To Top
Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.