e107sk.com

Options field

How to customize options field
on Friday 18 October 2019
comments: 0

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'>
".ADMIN_EDIT_ICON."</a>";

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;

0 Comments

Other links

Follow us