Checkbox Pill

The checkbox-pill lets you add a field for selecting data.

Inline style.

Checkbox Pill Inline

List Style.

Checkbox Pill List

Parameters

Here are the parameters in adding checkbox-pill.

id
string | required

a unique slug-like string to use as an id and also as index in saving data in database.

label
string | optional

the label of the field.

description
string | optional

the description of the field and display under the label.

section
string | required

the section where the field will be displayed.

default
array | optional

the default value of the field.

Note: default value must exist in choices.

priority
integer | optional

determines the order of fields in section.

choices
array | optional

list of choices.

style
string | optional

the style of the checkbox pill.

Note: style values are 'inline' and 'list' default is 'list'

Example


Yano::field( 'checkbox-pill', [
   'id'            => 'checkboxpilldb1',
   'label'         => 'Select Fruits',
   'description'   => 'Fruit list description',
   'section'       => 'section_id',
   'priority'      => 1,
   'choices'       => [
      'apple'      => 'Apple',
      'orange'     => 'Orange',
      'grape'      => 'Grape',
      'mango'      => 'Mango',
      'cherry'     => 'Cherry',
      'berry'      => 'Berry',
      'melon'      => 'Melon'	
   ]
]);

Example with default value! note: default value must exist in choices.


Yano::field( 'checkbox-pill', [
   'id'            => 'checkboxpilldb1',
   'label'         => 'Select Fruits',
   'description'   => 'Fruit list description',
   'section'       => 'section_id',
   'default'       => [ 'apple', 'orange' ],
   'priority'      => 1,
   'choices'       => [
      'apple'      => 'Apple',
      'orange'     => 'Orange',
      'grape'      => 'Grape',
      'mango'      => 'Mango',
      'cherry'     => 'Cherry',
      'berry'      => 'Berry',
      'melon'      => 'Melon'	
   ]
]);

Example with style! note: style values are inline and list default is list


Yano::field( 'checkbox-pill', [
   'id'            => 'checkboxpilldb1',
   'label'         => 'Select Fruits',
   'description'   => 'Fruit list description',
   'section'       => 'section_id',
   'default'       => [ 'apple', 'orange' ],
   'priority'      => 1,
   'style'         => 'inline',
   'choices'       => [
      'apple'      => 'Apple',
      'orange'     => 'Orange',
      'grape'      => 'Grape',
      'mango'      => 'Mango',
      'cherry'     => 'Cherry',
      'berry'      => 'Berry',
      'melon'      => 'Melon'	
   ]
]);

Usage

The yano_get_special_values() function is recommended to retrieve data.


// Returns a array
$choices = yano_get_special_values('checkboxpilldb1');