Control: Multi-control

 Show all Hide all

This field type inserts the controls specified by an sql query into the normal flow of controls on the page.

Start value: Value that is passed to the stored procedure specified in the Sql field as the parameter @id. It is also passed to the insert / update procedure of the newedit.aspx page.
Return value: Two modes are supported:

In the temp table mode all data from the controls is passed to a temporary table. The start value is returned to the insert / Update procedure. The name of the temporary table is also passed to the insert update procedure in a parameter called <fieldname>TableName. The temporary table always has the columns Id and Value, both nvarchar. If the multi-control contains controls that provide extra parameters such as the file control, the parameters are added as columns with the same names to the temp table.

In the classic mode a '¤' separated list of values is passed as a parameter.

Control container: NewEdit

Supported in: NewEdit

SQL

SQL Call: Control specifications (mandatory)

Return one row for each control to insert.
Supports custom errors: No
May modify database: No

Parameters:

@id mandatory string
Value supplied from the database record being edited or default value of the field depending on the action parameer to newedit.aspx.

Resultset: Control specifications

Return field information for the controls to insert.
Repeat mode: repeated exactly once
Row count: zero or more rows

Columns:

<other> optional string
You may also specify any other field information supported by the fieldtype. If it is not supported by all controls in the resultset it should be set to null for the controls that don't support it. See documentation for the control type in question for information on what additional options may be specified.
ButtonJavaScript<xxx> optional string
Inserts a button next to the control that is used to execute the JavaScript supplied here. <xxx> is an arbitrary text that can be empty if only one button is required.
ButtonJavaScript<xxx>_Label optional string
The label for the JavaScript button <xxx>.
defaultvalue mandatory string
Default value for field. Can contain other fields for value dependency.
DefaultValueSql optional bigint
SQL that evaluates default value for field. Can contain other fields for value dependency.
description optional string
Description for the control.
enabledjavascript optional string
Javascript that controls whether the control is enabled for edit. The value of a disabled field is always NULL.
FieldInfoId optional int
ID of field information to base the dynamic field on. All properties not explicitly overridden by dynamic field information will be copied from this field. The referenced field must be found in the menu item's field tables.
fieldlabel optional string
Label for the control
fieldname optional string
The name of the field if referring to it from other controls.You should avoid using special characters in the fieldname column. If you need to pass complex data to the insert/update procedure then use the id-column instead.
fieldtype optional string
The type of control to create.
Possible value Description
boolean checkbox
boolean dropdown
colorpicker
date
datetime
dropdown
file
heading
hidden
html
listbox
multi-listbox
multi-picker
multirow
password
textarea
textbox
textbox with dropdown
textbox with popup
time
uneditable text
height optional int
The height of the control.
id optional string
A custom id value identifying this control. This is passed back as the column Id if the temporary table mode is used.
nullchoice optional bit
Specify 1 to allow null values or 0 to disallow null values.
onchangejavascript optional string
Javascript to run when the value of the control has changed.
Placeholder optional string
Text shown when the field is empty.
sql optional string
Sql for the control.
value optional string
Start value of the control. Only applicable in edit and duplicate modes. In new mode the default value is used as start value.
width optional int
The width of the control.
visiblejavascript optional string
Javascript that determines when the control is visible. Supports references to other controls.

Examples

Multicontrol procedure

Example multicontrol procedure. In the example an input field per row in MultiControlTable will be created and if there is a corresponding value in MultiControlTable it will populate the field.

The [FieldName] column is only needed if you have dependencies.

CREATE PROCEDURE Example.MultiControlTable_MultiControl
	@Id		int = NULL
AS
BEGIN

	SELECT
		-- Name that can be used to reference the field in visibility, defaultvalue and SQL fields
		'MultiControlTable' + CONVERT(varchar(100), MCTT.MultiControlTableTypeId) AS [FieldName],
		MCTT.MultiControlTableTypeName AS [FieldLabel],
		MCTT.Description,
		-- Id value passed to InsertUpdate procedure in Id column to identify value
		MCTT.MultiControlTableTypeId AS [Id],
		MCT.Value,
		-- Use "SQL: " an in regular field info to run a SQL statement
		MCTT.DefaultValue,
		MCTT.CanAllowNullValues AS [NullChoice],
		-- The different field types in Softadmin are valid choices
		CASE
			WHEN MCTT.IsDropdown = 1 THEN
				'dropdown'
			WHEN MCTT.IsHeading = 1 THEN
				'heading'
			WHEN MCTT.IsTextbox = 1 THEN
				'textbox'
		END AS [FieldType],
		-- SQL statement for field types that require it
		MCTT.SQL,
		MCTT.Height,
		MCTT.Width,
		-- Visibility field
		CASE
			WHEN MCTT.MultiControlTableTypeId = 4 THEN
				'{MultiControlTable3}=="test"'
		END AS [VisibleJavascript]
	FROM
		-- One field per row in Example.MultiControlTableType
		Example.MultiControlTableType MCTT
		-- Get value from Example.MultiControlTable if it exists
		LEFT JOIN Example.MultiControlTable MCT ON
			MCT.MultiControlTableTypeId = MCTT.MultiControlTableTypeId AND
			MCT.RowId = @Id
	ORDER BY
		MCTT.MultiControlTableTypeName

END

Best practice

Name of stored procedure

The stored procedure should be named "<Schema>.<TableMultiControlGetsRowsFrom>_MultiControl".