Formkit Elements

formkitTags

Creates a tags element with a title, that allows you to select multiple items from a list.

The value that is submitted will have the following convention – {variable}_{option key}. In the example below the submitted variables’ keys will be example_tags_first_tag and example_tags_second_tag. Their value will be 1 or 0 depending on if they are checked or not.

Passing pre-selected values is done with an array where the key is the key of the tag and the value is a boolean.

Available Parameters

title

String | The field's title

items

Array | An array of items that should be passed in key - value pairs

params

Array | Additional parameters such as variable and value

error

String | Default: false | Custom error message

Example

$this->formkitTags('Tags Example', array(
    'first_tag' => 'First Tag',
    'second_tag' => 'Second Tag'
), array(
    'variable' => 'example_tags'
));

// Tags with pre-selected values
$this->formkitTags('Tags Example', array(
    'first_tag' => 'First Tag',
    'second_tag' => 'Second Tag'
), array(
    'variable' => 'example_tags',
    'value' => array(
        'first_tag' => 1
    )
));

formkitSlider

Creates a slider component with a title and dynamically displaying the current value.

Available Parameters

title

String | The field title

variablename

String | The variable name

defaultvalue

Number | The slider's default value

minvalue

Number | The slider's minimal allowed value

maxvalue

Number | The slider's maximal allowed value

step

Number | The slider movement step

Example

$this->formkitSlider('Example Slider', 'example_slider', 100, 0, 500, 10);

formkitRadiobuttons

Creates a radio buttons element. Works similarly to formkitTags but allows only one selected option at a time. Unlike tags, selected value is passed as a string.

Available Parameters

title

String | The field title

items

Array | The radio items

params

Array | Default: false | Additional params such as variable name and value

error

String | Default: false | Custom error message

Example

$this->formkitRadiobuttons('Example Radio Buttons', array(
    'first_option' => 'First Option',
    'second_option' => 'Second Option',
), array(
    'variable' => 'example_radio'
));

// Radio buttons with pre-selected value
$this->formkitRadiobuttons('Example Radio Buttons', array(
    'first_option' => 'First Option',
    'second_option' => 'Second Option',
), array(
    'variable' => 'example_radio',
    'value' => 'first_option'
));

formkitCheckbox

Creates a single checkbox element with a title.

Available Parameters

variable

String | The variable name

title

String | The field title

params

Array | Default: false | An array of parameters

error

String | Default: false | Custom error message

Example

$this->formkitCheckbox('example_checkbox', 'Example Checkbox');

formkitCheckboxes

Creates a checkboxes component. Under the hood it uses the formkitRadiobuttons component, but will have style differences.

Available Parameters

title

String | The field title

items

Array | Array of items

params

Array | Default: false | Additional parameters such as variable

error

String | Default: '' | Custom error message

Example

$this->data->scroll[] = $this->formkitCheckboxes('Example Checkboxes', array(
    'first_check' => 'First Check',
    'second_check' => 'Second Check'
), array(
    'variable' => 'example_check'
));

formkitTextarea

Creates a textarea component.

Available Parameters

variable

String | The variable name

title

String | The field title

hint

String | Hint for the textarea

type

String

error

String | Custom error message

Example

$this->formkitTextarea('example_textarea', 'Example Textarea', 'Example', '', '');

formkitDate

Creates a datepicker component. Allows you to specify date, month and year. Date is returned as three separate variables using the following convention – {variable name}_day, {variable name}_month and {variable_name}_year. In the example bellow those would be – example_date_day, example_date_month and example_date_year.

Available Parameters

title

String | The field title

variable

String | The variable name

params

Array | Default: false | Additional parameters

error

String | Default: false | Custom error message

Example

$this->formkitDate('Example Date', 'example_date');