CmsFormUtils
in package
A static class providing functionality for building forms.
Tags
Table of Contents
Methods
- create_dropdown() : string
- Create an advanced select field.
- create_option() : string
- A simple recursive utility function to create an option, or a set of options for a select list or multiselect list.
- create_options() : string
- Create a series of options suitable for use in a select input element.
- create_textarea() : string
- A method to create a text area control.
Methods
create_dropdown()
Create an advanced select field.
public
static create_dropdown(string $name, array<string|int, mixed> $list_options, string|array<string|int, string> $selected[, array<string|int, mixed> $params = array() ]) : string
Parameters
- $name : string
-
The name attribute for the select name
- $list_options : array<string|int, mixed>
-
Options as per the CmsFormUtils::create_options method
- $selected : string|array<string|int, string>
-
Selected value as per the CmsFormUtils::create_option method
- $params : array<string|int, mixed> = array()
-
Array of additional options including: multiple,class,title,id,size
Return values
string —The HTML content for the
create_option()
A simple recursive utility function to create an option, or a set of options for a select list or multiselect list.
public
static create_option(array<string|int, mixed> $data[, array<string|int, string>|string $selected = null ]) : string
Accepts an associative 'option' array with at least two populated keys: 'label' and 'value'. If 'value' is not an array then a single '
i.e: $tmp = array('label'=>'myoptgroup','value'=>array( array('label'=>'opt1','value'=>'value1'), array('label'=>'opt2','value'=>'value2') ) );
The 'option' array can have additional keys for 'title' and 'class'
i.e: $tmp = array('label'=>'opt1','value'=>'value1','title'=>'My title','class'=>'foo');
Parameters
- $data : array<string|int, mixed>
-
The option data
- $selected : array<string|int, string>|string = null
-
The selected elements
Tags
Return values
string —The generated
create_options()
Create a series of options suitable for use in a select input element.
public
static create_options(array<string|int, mixed> $options[, mixed $selected = '' ]) : string
This method is intended to provide a simple way of creating options from a simple associative array but can accept multiple arrays of options as specified for the CmsFormUtils::create_option method
i.e: $tmp = array('value1'=>'label1','value2'=>'label2'); $options = CmsFormUtils::create_options($tmp);
i.e: $tmp = array( array('label'=>'label1','value'=>'value1','title'=>'title1'), array('label'=>'label2','value'=>'value2','class'=>'class2') ); $options = CmsFormUtils::create_options($tmp)
Parameters
- $options : array<string|int, mixed>
- $selected : mixed = ''
Tags
Return values
stringcreate_textarea()
A method to create a text area control.
public
static create_textarea(array<string|int, mixed> $parms) : string
parameters: name = (required string) name attribute for the text area element. id = (optional string) id attribute for the text area element. If not specified, name is used. class/classname = (optional string) class attribute for the text area element. Some values will be added to this string. default is cms_textarea forcemodule = (optional string) used to specify the module to enable. If specified, the module name will be added to the class attribute. enablewysiwyg = (optional boolan) used to specify wether a wysiwyg textarea is required. sets the language to html. wantedsyntax = (optional string) used to specify the language (html,css,php,smarty) to use. If non empty indicates that a syntax hilighter module is requested. cols/width = (optional integer) columns of the text area (css or the syntax/wysiwyg module may override this) rows/height = (optional integer) rows of the text area (css or the syntax/wysiwyg module may override this) maxlength = (optional integer) maxlength attribute of the text area (syntax/wysiwyg module may ignore this) required = (optional boolean) indicates a required field. placeholder = (optional string) placeholder attribute of the text area (syntax/wysiwyg module may ignore this) value/text = (optional string) default text for the text area, will undergo entity conversion. encoding = (optional string) default utf-8 encoding for entity conversion. addtext = (optional string) additional text to add to the textarea tag. cssname = (optional string) Pass this stylesheet name to the WYSIWYG area if any.
note: if wantedsyntax is empty, AND enablewysiwyg is false, then just a plain text area is creeated.
Parameters
- $parms : array<string|int, mixed>
-
An associative array with parameters.