Kentico CMS 6.0 Developer's Guide

Form control parameters

Form control parameters

Previous topic Next topic Mail us feedback on this topic!  

Form control parameters

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

It is possible to define parameters for form controls that can be used to further specify the behaviour or appearance of the generated form fields. Parameters can greatly increase the flexibility of a form control, since they provide additional configuration options for individual fields that use the control. This allows you to reuse the same control without having to develop a new one for every small difference in functionality or design.

 

To access the parameters of a form control, edit (Edit) the given control in Site Manager -> Development -> Form controls and switch to the Properties tab. Here, you can manage the fields that represent individual parameters.

 

devguide_clip0117

 

As you may have noticed, the parameters themselves are created using a field editor and the form used to edit their values is based on the standard form engine. The editing interface for every parameter is provided by a selected form control, which means you can create completely custom parameters according to your own requirements.

 

The defined parameters are then displayed when the given form control is selected in the field editor of an object. You can view and configure them under the Editing control settings section of the given field.

 

devguide_clip0128

 

Any parameter values entered here will be applied to the given field.

 

 

 

Warning!

 

Removing or modifying the parameters of the built-in form controls may cause the system to behave incorrectly in some cases, since the controls are used in various parts of the Kentico CMS interface.

 

We recommend implementing new form controls when creating custom fields.

 

Handling parameters in the code of custom form controls

 

In order to be reflected by the field in the resulting form, each parameter must be processed in the code of the form control. The following methods can be used to access the value of a parameter:

 

GetValue("<ParameterName>")

SetValue("<ParameterName>", Object value)

 

Replace the <ParameterName> expression with the Column name of the parameter that you wish to get or set. These two methods are inherited from the FormEngineUserControl class, so they are available for every form control. For easy storage and usability, it is recommended to define a separate property for every parameter (as a member of the control's class). Once you have the value of the parameter, you can implement code that modifies the control accordingly.

 

For more details, please see the example in the Developing form controls topic, which demonstrates how a parameter can be added to a form control and handled in the code.