Defining attributes: Difference between revisions
From LimeSurvey Manual
No edit summary |
m Text replacement - " enclose="div"" to "" |
||
(One intermediate revision by one other user not shown) | |||
Line 14: | Line 14: | ||
Example: | Example: | ||
<syntaxhighlight lang="php | <syntaxhighlight lang="php"> | ||
protected $attributes = array( | protected $attributes = array( |
Latest revision as of 15:06, 16 February 2022
Defining attributes for question types.
Attributes for question types are all configurable, non default, aspects of a question. A good example of an attribute is question text.
Question attributes are defined using an array with the name of the attribute as a key. An attribute definition supports several keys.
- type - string: The data type of the attribute. Supported types are ('html', 'string', 'boolean', 'select')
- localized - boolean: Whether this attribute should be configurable per language.
- advanced - boolean: Whether this attribute should be shown in the default or advanced tab.
- label - string: The label of the attribute in English (this is localized by the admin interface).
- options - array(string-string): Contains the options for an attribute of type 'select'.
- default - mixed: Contains the default value for the attribute.
Example:
protected $attributes = array(
'question' => array(
'type' => 'html',
'localized' => true,
'label' => 'Question text:'
),
'help' => array(
'type' => 'html',
'localized' => true,
'label' => 'Help text:'
),
'mandatory' => array(
'type' => 'boolean',
'label' => 'Mandatory:'
),
'display' => array(
'label' => 'Display using:',
'type' => 'select',
'options' => array(
'radio' => 'Radio buttons',
'dropdown' => 'Dropdown list'
),
'localized' => false,
'advanced' => false,
'default' => 'dropdown'
)
);