Confetti Bits

cb-templates-forms.php

Table of Contents

Functions

cb_templates_get_text_input()  : mixed
CB Templates Get Text Input
cb_text_input()  : mixed
CB Text Input
cb_templates_get_select_input()  : mixed
CB Templates Get Select Input
cb_templates_get_select_options()  : mixed
CB Templates Get Select Options
cb_select_input()  : mixed
Confetti Bits Select Input
cb_templates_get_number_input()  : mixed
CB Templates Get Number Input
cb_number_input()  : mixed
CB Number Input
cb_templates_get_file_input()  : mixed
Confetti Bits Get File Input.
cb_file_input()  : mixed
Confetti Bits File Input
cb_templates_get_submit_input()  : mixed
CB Templates Get Submit Input.
cb_submit_input()  : mixed
CB Submit Input
cb_templates_get_hidden_input()  : mixed
CB Templates Get Hidden Input
cb_hidden_input()  : mixed
CB Hidden Input
cb_templates_get_checkbox_input()  : mixed
CB Templates Get Checkbox Input
cb_checkbox_input()  : mixed
CB Checkbox Input
cb_templates_get_dropzone_input()  : mixed
CB Format Dropzone Input
cb_dropzone_input()  : mixed
CB Dropzone Input
cb_templates_get_toggle_switch()  : mixed
Alias for cb_templates_get_toggle_switch_input().
cb_templates_get_toggle_switch_input()  : string
Gets markup for a toggle switch input.
cb_toggle_switch()  : mixed
CB Toggle Switch
cb_templates_get_form()  : string
CB Templates Get Form
cb_form()  : mixed
Outputs the markup for a form element.
cb_templates_get_form_module()  : string
Gets the markup for a form module.
cb_templates_get_form_button()  : string
Returns formatted markup for a form button. Note that this should not be used as a submit button; we typically use input[type=submit] for that functionality. Here we'll default to button[type=button] to ensure that we can have it do what we want and not make the app have a heart attack.
cb_form_module()  : mixed
Outputs the form module's markup.
cb_templates_get_form_output()  : mixed
Dynamically populates markup and input elements for a form.
cb_templates_recursive_helper()  : string
A recursive helper function to help us process complex content trees.
cb_templates_get_time_picker_input()  : string
Gets markup for a time picker.
cb_time_picker_input()  : mixed
Outputs markup for a time picker.
cb_templates_get_date_picker_input()  : string
Gets markup for a date picker input.
cb_templates_get_datetime_picker_input()  : string
Gets markup for both date and time inputs on one line.
cb_datetime_picker()  : mixed
Outputs markup for a datetime picker input.
cb_templates_get_datetime_local_input()  : string
Formats markup for a datetime-local input.
cb_datetime_local_input()  : mixed
Outputs markup for a datetime-local input.
cb_templates_get_date_input()  : mixed
Outputs markup for an actually nice date input. Uses Bootstrap styling and plugs in some custom data based on arguments passed.
cb_date_input()  : mixed
Outputs markup for a pretty date input.
cb_templates_get_time_selector_input()  : mixed
cb_time_selector_input()  : mixed

Functions

cb_templates_get_text_input()

CB Templates Get Text Input

cb_templates_get_text_input([array<string|int, mixed> $args = [] ]) : mixed

Formats a text input that plays nice with our scripts.

Parameters
$args : array<string|int, mixed> = []

A list of arguments {

Tags
type

string label The label for the input

type

string name The form input and label name

type

string placeholder The placeholder for the input

type

string value The default value of the input

type

bool $disabled Disables the element if true. Default false.

type

bool $hidden Hides the element if true. Default false.

type

bool $textarea Changes markup to instead be a textarea input.

type

arr $container_classes Provides the option to add container classes.

}

since
2.3.0

cb_text_input()

CB Text Input

cb_text_input([array<string|int, mixed> $args = [] ]) : mixed

Outputs the text input.

Parameters
$args : array<string|int, mixed> = []

The array of arguments that get passed to the getter. It would be wise to check what all is needed.

Tags
since
2.3.0

cb_templates_get_select_input()

CB Templates Get Select Input

cb_templates_get_select_input([array<string|int, mixed> $args = array() ]) : mixed

Creates a select input element.

Parameters
$args : array<string|int, mixed> = array()

Accepts a bunch of optional arguments.

Tags
type

string $for The name and for label of the select element.

type

string $label The readable label of the element.

type

array $select_options The options housed inside the select element. Accepts a 2D array of option names and their attributes, which get pushed to cb_select_options. Required. @see cb_select_options()

since
2.3.0

cb_templates_get_select_options()

CB Templates Get Select Options

cb_templates_get_select_options([array<string|int, mixed> $args = [] ]) : mixed

Takes care of some of the business for making select inputs.

Parameters
$args : array<string|int, mixed> = []

Arguments for the select input, listed below. Required. @type string $name The name of the option. Required. @type array $options The input values, and whether they are disabled or selected. @type string $value The value for the option. Required. @type bool $disabled Whether the option is disabled or not. Optional. @type bool $selected Whether the option is selected by default. Optional.

Tags
see
cb_select_input()
since
2.3.0

cb_select_input()

Confetti Bits Select Input

cb_select_input([array<string|int, mixed> $args = [] ]) : mixed

Outputs the select input.

Parameters
$args : array<string|int, mixed> = []

The array of arguments that get passed to the getter. It would be wise to check what all is needed.

Tags
see
cb_get_select_input()
since
2.3.0

cb_templates_get_number_input()

CB Templates Get Number Input

cb_templates_get_number_input([array<string|int, mixed> $args = [] ]) : mixed

Use this to create a number input element.

Parameters
$args : array<string|int, mixed> = []

An array of arguments for the input element. Details below. All settings are optional.

Tags
type

string $label The label used for the number input. Default 'Number' Optional.

type

string $for Used for the for attribute in the label, and the name attribute and id for the input. Default 'cb_number' Optional.

type

int $value The default value of the input element. Optional.

type

int|string $placeholder The placeholder for the input element. Optional.

type

bool $disabled Whether the element is disabled. Default false. Optional.

type

bool $readonly Whether the element is readonly. Default false. Optional.

since
2.3.0

cb_number_input()

CB Number Input

cb_number_input([array<string|int, mixed> $args = [] ]) : mixed

Outputs the number input.

Parameters
$args : array<string|int, mixed> = []

The array of arguments that get passed to the getter. It would be wise to check what all is needed.

Tags
since
2.3.0

cb_templates_get_file_input()

Confetti Bits Get File Input.

cb_templates_get_file_input([array<string|int, mixed> $args = [] ]) : mixed

Creates a file input element that accepts the specified filetypes.

Parameters
$args : array<string|int, mixed> = []

An array of arguments for the input element. All optional.

@type string $label The label for the input. Default 'Upload a File'. @type string $class Custom class attribute for file input. @type string $name The value used in the for attribute of the label and the name and id attributes of the input. Default 'cb_file_upload'. @type bool $required Whether or not the field is required. Default false. @type bool $multiple Whether or not the field allows multiple files. Default false. @type bool $capture Whether or not the field allows the use of a camera. Default false. @type bool $disabled Whether or not the field is disabled. Default false. @type array $accepts An array of filetypes that the input accepts. Accepts either MIME type structures or filetype structures. Should be compliant with your Wordpress configuration. Default empty.

Tags
since
2.1.0

cb_file_input()

Confetti Bits File Input

cb_file_input([array<string|int, mixed> $args = [] ]) : mixed

Outputs the file input.

Parameters
$args : array<string|int, mixed> = []

The array of arguments that get passed to the getter. It would be wise to check what all is needed.

Tags
since
2.1.0

cb_templates_get_submit_input()

CB Templates Get Submit Input.

cb_templates_get_submit_input([array<string|int, mixed> $args = [] ]) : mixed

Creates a submit input element that submits a form.

Parameters
$args : array<string|int, mixed> = []

An array of arguments for the input element. All optional.

@type string $id The value used in the id attribute of the input. Default empty. @type value $value Value for the submit input. Default "Submit". @type bool $disabled Whether or not the field is disabled. Default false.

Tags
since
2.3.0

cb_submit_input()

CB Submit Input

cb_submit_input([array<string|int, mixed> $args = [] ]) : mixed

Outputs the submit input markup.

Parameters
$args : array<string|int, mixed> = []

The array of arguments that get passed to the getter. It would be wise to check what all is needed.

Tags
since
2.1.0

cb_templates_get_hidden_input()

CB Templates Get Hidden Input

cb_templates_get_hidden_input([array<string|int, mixed> $args = [] ]) : mixed

Creates a hidden input that's either ready to receive a value or has a preset value.

Suggested utilities are getting things like user ids, logged-in usernames, emails, or empty inputs that get calculated on the page via javascript. We probably haven't written things like that yet, so you may have to set it up for your needs.

Parameters
$args : array<string|int, mixed> = []

An array of arguments for the input. Name, id, value, disabled, multiple.

Tags
since
2.3.0

cb_hidden_input()

CB Hidden Input

cb_hidden_input([array<string|int, mixed> $args = [] ]) : mixed

Outputs the hidden input markup.

Parameters
$args : array<string|int, mixed> = []

The array of arguments that get passed to the getter. It would be wise to check what all is needed.

Tags
since
2.3.0

cb_templates_get_checkbox_input()

CB Templates Get Checkbox Input

cb_templates_get_checkbox_input([array<string|int, mixed> $args = [] ]) : mixed

Creates a checkbox input with a label and as many options as you want.

Parameters
$args : array<string|int, mixed> = []

An array of options for each input you want to include, structured in a 2D array of option names => array of option parameters. {

			@type	string	$name		The value used in the for, name, and id attributes.
			@type	string	$label		The label for the option.
			@type	string	$value		The value of the option.
			@type	bool	$checked	Whether the field is checked or not.
			@type	bool	$disabled	Whether the field is disabled or not.

}

Tags
since
2.2.0

cb_checkbox_input()

CB Checkbox Input

cb_checkbox_input([array<string|int, mixed> $args = [] ]) : mixed

Outputs the checkbox input markup.

Parameters
$args : array<string|int, mixed> = []

The array of arguments that get passed to the getter. It would be wise to check what all is needed.

Tags
since
2.1.0

cb_templates_get_dropzone_input()

CB Format Dropzone Input

cb_templates_get_dropzone_input([array<string|int, mixed> $args = [] ]) : mixed

Creates a hidden input and a container that can be used for drag-and-drop file uploads.

Parameters
$args : array<string|int, mixed> = []

An array of arguments for the input. Name, id, value, disabled, multiple, etc.

Tags
since
2.1.0

cb_dropzone_input()

CB Dropzone Input

cb_dropzone_input([array<string|int, mixed> $args = [] ]) : mixed

Outputs the hidden input markup.

Parameters
$args : array<string|int, mixed> = []

The array of arguments that get passed to the getter. It would be wise to check what all is needed.

Tags
since
2.1.0

cb_templates_get_toggle_switch()

Alias for cb_templates_get_toggle_switch_input().

cb_templates_get_toggle_switch([mixed $args = [] ]) : mixed
Parameters
$args : mixed = []
Tags
since
2.2.0

cb_templates_get_toggle_switch_input()

Gets markup for a toggle switch input.

cb_templates_get_toggle_switch_input([array<string|int, mixed> $args = [] ]) : string
Parameters
$args : array<string|int, mixed> = []

{ An array of options for each input you want to include, structured in a 2D array of options.

	@type	string	$name		The value used in the for, name, and id attributes.
	@type	string	$label		The label for the option.
	@type	string	$value		The value of the option.
	@type	bool	$checked	Whether the field is checked or not.
	@type	bool	$disabled	Whether the field is disabled or not.

}

Tags
since
3.0.0
Return values
string

The formatted markup.

cb_toggle_switch()

CB Toggle Switch

cb_toggle_switch([array<string|int, mixed> $args = [] ]) : mixed

Outputs toggle switch markup.

Parameters
$args : array<string|int, mixed> = []

An array of options for each input you want to include, structured in a 2D array of options.

@type string $name The value used in the for, name, and id attributes. @type string $label The label for the option. @type string $value The value of the option. @type bool $checked Whether the field is checked or not. @type bool $disabled Whether the field is disabled or not.

Tags
since
2.2.0

cb_templates_get_form()

CB Templates Get Form

cb_templates_get_form([mixed $args = array() ]) : string

Gets the markup for a form element.

Parameters
$args : mixed = array()
Tags
since
2.3.0
Return values
string

The formatted markup.

cb_templates_get_form_module()

Gets the markup for a form module.

cb_templates_get_form_module([array<string|int, mixed> $args = [] ]) : string

Use this when you want the whole UI kit and caboodle on the Confetti Bits dashboard (i.e., you just want a form inside of a module).

Parameters
$args : array<string|int, mixed> = []

{ An array of arguments.

@type string $component The name of the component.
@type string $method The form method.
@type array $classes Classes for the form element.
@type string $action The URL for the form handler.
@type string $output The markup that goes into the form.
@type string $enctype The encoding for the form.
@type string $autocomplete Whether the form should include
							  autocomplete features.

}

Tags
since
2.3.0
Return values
string

The formatted markup of the form module.

cb_templates_get_form_button()

Returns formatted markup for a form button. Note that this should not be used as a submit button; we typically use input[type=submit] for that functionality. Here we'll default to button[type=button] to ensure that we can have it do what we want and not make the app have a heart attack.

cb_templates_get_form_button([array<string|int, mixed> $args = [] ]) : string
Parameters
$args : array<string|int, mixed> = []

{ An associative array of arguments. Accepts various attributes of button elements, with support for your own custom attributes as well. }

Tags
since
3.0.0
Return values
string

The formatted markup.

cb_form_module()

Outputs the form module's markup.

cb_form_module([array<string|int, mixed> $args = [] ]) : mixed
Parameters
$args : array<string|int, mixed> = []

{ @see cb_templates_get_form_module() }

Tags
since
2.3.0

cb_templates_get_form_output()

Dynamically populates markup and input elements for a form.

cb_templates_get_form_output([array<string|int, mixed> $args = [] ]) : mixed

When given a heading, a component, and input arguments, this function can generate an entirely unique set of markup to put into a form element. It naturally prepends the "cb_" prefix to the beginning to stick within our namespace, then supplies the value supplied by the 'component' argument, and finally appends the value defined in the input_args['name'] argument to create a (hopefully) entirely unique input element, with the given type supplied in the input_args['type'] argument. Argument... Argument... Argument. Doesn't sound like a word anymore.

Parameters
$args : array<string|int, mixed> = []

{ An array of - you guessed it - arguments.

@type string $component The name for the component. Used
						   to generate unique name and id
						   attributes in the input elements.
@type string $heading The heading to use in the output.
						 Basically for flavor.

}

cb_templates_recursive_helper()

A recursive helper function to help us process complex content trees.

cb_templates_recursive_helper([mixed $node = [] ]) : string

It'll recurse through each node that's labeled as a 'new_node' and return a string of content that's ready to echo out into the world.

Parameters
$node : mixed = []
Tags
since
3.0.0
Return values
string

The glorious content.

cb_templates_get_time_picker_input()

Gets markup for a time picker.

cb_templates_get_time_picker_input([array<string|int, mixed> $args = [] ]) : string
Parameters
$args : array<string|int, mixed> = []

{ An associative array of arguments for the time picker.

@type string $name The name attribute for the input.
@type string $label The label for the input.

@type string $classes The classes for the input. @type string $value The value for the input. @type string $placeholder The placeholder for the input. @type string $min The minimum time for the input. @type string $max The maximum time for the input. @type string $step The step for the input.

}

Tags
since
3.0.0
Return values
string

The markup for the time picker input.

cb_templates_get_date_picker_input()

Gets markup for a date picker input.

cb_templates_get_date_picker_input([array<string|int, mixed> $args = [] ]) : string
Parameters
$args : array<string|int, mixed> = []

{ An associative array of arguments for the inputs.

@type string			$label 			A label for the input.

@type string			$name			The name attribute for the input. Required.

@type string 		$placeholder	A placeholder date string.
										Default current date, formatted 'm/d/Y'.

@type string 		$value			A preset value for the input.

@type bool 			$disabled 		Whether the input should be disabled by default.
								  		Default false.

@type bool 			$hidden 		Whether the input should be hidden by default.
					  					Default false.

@type bool 			$required 		Whether the input should be required by default.
								  		Default false.

@type string|array	$classes 		An array of classes that will be added
										to the container element.
										Default ['cb-date-picker'].

}

Tags
since
3.0.0
Return values
string

The formatted markup for the inputs.

cb_templates_get_datetime_picker_input()

Gets markup for both date and time inputs on one line.

cb_templates_get_datetime_picker_input([array<string|int, mixed> $args = [] ]) : string
Parameters
$args : array<string|int, mixed> = []

{ An associative array of arguments for the inputs.

@type array $date {
    @see cb_templates_get_date_picker_input()
}

@type array $time {
    @see cb_templates_get_time_picker_input()
}

}

Tags
since
3.0.0
Return values
string

The formatted markup for the inputs.

cb_templates_get_datetime_local_input()

Formats markup for a datetime-local input.

cb_templates_get_datetime_local_input([array<string|int, mixed> $args = [] ]) : string

I cannot believe I didn't know this existed until so recently.

Parameters
$args : array<string|int, mixed> = []

{ An associative array of arguments.

@type string $label A label for the input.
@type string $name A name for the input.
@type string $placeholder A placeholder for the input.
@type string $value A default value for the input.
@type bool $disabled Whether the input is disabled by default.
@type bool $hidden Whether the input is hidden by default.
@type bool $required Whether the input is required by default.
@type array $classes An array of class selectors to give the input.

}

Tags
since
3.0.0
Return values
string

The formatted markup.

cb_templates_get_date_input()

Outputs markup for an actually nice date input. Uses Bootstrap styling and plugs in some custom data based on arguments passed.

cb_templates_get_date_input([array<string|int, mixed> $args = [] ]) : mixed
Parameters
$args : array<string|int, mixed> = []

{ An optional array of arguments. }

cb_date_input()

Outputs markup for a pretty date input.

cb_date_input([mixed $args = [] ]) : mixed
Parameters
$args : mixed = []
Tags
since
3.0.0

cb_templates_get_time_selector_input()

cb_templates_get_time_selector_input([mixed $args = [] ]) : mixed
Parameters
$args : mixed = []

cb_time_selector_input()

cb_time_selector_input([mixed $args = [] ]) : mixed
Parameters
$args : mixed = []

        
On this page

Search results