Knowledge Base / Category / Admin UI stuff

Admin UI stuff

Multicheckbox field

How to set multicheck field

Multicheck field in admin UI

Inspiration (or core check): admin/newspost.php and field: news_render_type

=> array(
	'title' => "Checkbox check",
	'type' => 'dropdown',
	'writeParms'=>array('multiple'=>'1', 'optArray' => array('0'=>'first option', '1' => 'second option')),
	'width' => 'auto',
	'thclass' => 'left',
	'class' => 'left',
	'nosort' => false,

- 'data' - Data Type: string (it saves values separated by comma)
- 'type' - news uses dropdown, type checkbox is only for one value ( (0 or 1 is returned)

Inline editing:
type checkboxes allows multiselect


'multiple' - you can select more than one option

'optArray' - list of options. It's just example, you can fill it in init() method from database values. If you don't use keys, they will be 0,1,2..., but if you use keys, those ones will be used.

Boolean field

Boolean type

radio buttons with enable/disable
Default generated value by plugin builder:

'redirection_status' => array ( 'title' => 'Statust', 'type' => 'boolean',
'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => array (),
'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),

The result is ON/OFF switcher

Available parameters (from official documentation)

inverse 0 or 1 Invert the values of 0 and 1. ie. "Disabled" = 1 and "Enabled" = 0.
enabled (string) Alternate text to replace "Enabled"
disabled (string) Alternate text to replace "Disabled"

The parameter to change the text to YES/NO

'redirection_status' => array ( 'title' => 'Status', 'type' => 'boolean',
'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => array (), 'writeParms' => 'label=yesno',
'class' => 'left', 'thclass' => 'left',),

Options field

How to customize options field

By default, there are only edit and delete buttons.

Available options (only tested ones):

'noselector' => true, removes option to select displayed fields in read mode
'readParms'=>'sort=1' adds sort option. It doesn't work if you add buttons manually 

Add/change your own buttons:

Change type key to be able customize those buttons:

'options' => array(
'type' => 'method',
'width' => '10%',
'forced' => true,
'thclass' => 'center last',
'class' => 'center',
'sort' => false,

and  add

* Override the default Options field.
* @param $parms
* @param $value
* @param $id
* @param $attributes
* @return string
function options($parms, $value, $id, $attributes)
$text = '';if($attributes['mode'] == 'read')

return $text;

Result:  no buttons

Add edit button back:  ( f.e. if you want your own icons)

parse_str(str_replace('&', '&', e_QUERY), $query); //FIXME - FIX THIS
$query['action'] = 'edit';
$query['id'] = $id;
$query = http_build_query($query,null, '&');

$text = "<a href='".e_SELF."?{$query}' class='btn btn-default' title='".LAN_EDIT."' data-toggle='tooltip' data-placement='left'>

Result: only Edit button

Add delete button back: ( f.e. if you want your own icons)

$text .= $this->submit_image('menu_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]', array('class' => 'action delete btn btn-default'));

Result: Edit and Delete buttons

NEW 18.12.2019

Add delete button for record deleting (tested): 

$text .= $this->submit_image('etrigger_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]', 
array('class' => 'action delete btn btn-danger',
'icon'=> '<i class="fa fa-trash-o"></i>'));

The different way how to do the same thing:  (the same result as default options)

$att['readParms'] = 'sort=1';

if($attributes['mode'] == 'read')
$text = "<div class='btn-group'>";
//add your button here
$text .= $this->renderValue('options',$value,$att,$id);
//or here
$text .= "</div>"; 
return $text;