Tagging Select

The tagging-select lets you add a tagging select field.

Tagging Select

Parameters

Here are the parameters in adding tagging-select.

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 | requiredl

the section where the field will be displayed.

default
array | optional

the default value of the field.

Note: default values must exist in choices.

priority
integer | optional

determines the order of fields in section.

placeholder
string | optional

display placeholder in the field.

choices
array | optional

list of choices.

maxitem
int | optional

the limit number of tags.

Example


Yano::field( 'tagging-select', [
   'id'            => 'taggingselectdb1',
   'label'         => 'Enter your close friends',
   'description'   => 'description.',
   'section'       => 'section_id',
   'priority'      => 1,
   'maxitem'       => 5,
   'choices'       => [
      'apple'  => 'Apple',
      'grapes' => 'Grapes',
      'orange' => 'Orange',
      'banana' => 'Banana',
      'lemon'  => 'Lemon'	
   ]
] );

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


Yano::field( 'tagging-select', [
   'id'            => 'taggingselectdb1',
   'label'         => 'Enter your close friends',
   'description'   => 'description.',
   'section'       => 'section_id',
   'default'       => [ 'apple', 'grapes' ],
   'priority'      => 1,
   'maxitem'       => 5,
   'choices'       => [
      'apple'  => 'Apple',
      'grapes' => 'Grapes',
      'orange' => 'Orange',
      'banana' => 'Banana',
      'lemon'  => 'Lemon'	
   ]
] );

Example with using Utilities API. The Yano_Util::_get_pages() will return the page id and page title.


Yano::field( 'tagging-select', [
   'id'            => 'taggingselectdb1',
   'label'         => 'Enter your close friends',
   'description'   => 'description.',
   'section'       => 'section_id',
   'priority'      => 1,
   'maxitem'       => 5,
   'choices'       => Yano_Util::_get_pages()
] );

Usage

The yano_get_special_values() function is recommended to retrieve data.


// Returns a array
$tags = yano_get_special_values('taggingselectdb1');