PHP Class Carbon_Fields\Field\Checkbox_Field

Inheritance: extends Field
Show file Open project: htmlburger/carbon-fields

Protected Properties

Property Type Description
$option_value string The value that is saved in the database when this checkbox field is enabled.

Public Methods

Method Description
get_label ( ) : string Get the field label.
is_required ( ) : boolean Whether this field is required.
set_option_value ( string $value ) Modify the option value.
set_value_from_input ( array $input = null ) Load the field value from an input array based on it's name.
template ( ) Underscore template of the field.
to_json ( boolean $load ) : array Returns an array that holds the field data, suitable for JSON representation.

Method Details

get_label() public method

Label here is empty because it is displayed in the Underscore template.
public get_label ( ) : string
return string Label of the field.

is_required() public method

A single checkbox field is non-required by design.
public is_required ( ) : boolean
return boolean false

set_option_value() public method

Modify the option value.
public set_option_value ( string $value )
$value string New value

set_value_from_input() public method

If not enabled, set to empty string for easier data querying.
public set_value_from_input ( array $input = null )
$input array (optional) Array of field names and values. Defaults to $_POST

template() public method

Underscore template of the field.
public template ( )

to_json() public method

In addition to default data, option value and label are added. This data will be available in the Underscore template and the Backbone Model.
public to_json ( boolean $load ) : array
$load boolean Should the value be loaded from the database or use the value from the current instance.
return array

Property Details

$option_value protected property

The value that is saved in the database when this checkbox field is enabled.
protected string $option_value
return string