CmsFormUtils View code

A static class providing functionality for building forms.

package

CMS

license

GPL

author

Robert Campbell

since 2.0

Methods

create_option(array $data, array<mixed,string>|string $selected = null) : string

A simple recursive utility function to create an option, or a set of options for a select list or multiselect list.

static

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');

Arguments

array $data

The option data

array<mixed,string>|string $selected

The selected elements

Response

string

The generated

create_options(array $options, mixed $selected = '') : string

Create a series of options suitable for use in a select input element.

static

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)

Arguments

array $options

mixed $selected

Response

string

create_dropdown(string $name, array $list_options, string|array<mixed,string> $selected, array $params = array()) : string

Create an advanced select field.

static

Arguments

string $name

The name attribute for the select name

array $list_options

Options as per the CmsFormUtils::create_options method

string|array<mixed,string> $selected

Selected value as per the CmsFormUtils::create_option method

array $params

Array of additional options including: multiple,class,title,id,size

Response

string

The HTML content for the