Skip to content

Instantly share code, notes, and snippets.

@sebbdk
Created February 16, 2012 13:42
Show Gist options
  • Save sebbdk/1844896 to your computer and use it in GitHub Desktop.
Save sebbdk/1844896 to your computer and use it in GitHub Desktop.
Called like so:
echo $this->element('Crud/index', array(
'model' => 'ContentPage',
'columns' => array(
'name' => function($View, $item, $model) { return $View->Html->link($item[$model]['name'], array('action' => 'index', $item[$model]['id'])); },
'is_active',
'is_default',
),
'row_actions' => array(
'10_view' => function($View, $item, $model) { return $View->Html->link(__d('common', 'View'), array('action' => 'index', $item[$model]['id']), array('class' => 'btn')); },
'20_edit' => function($View, $item, $model) { return $View->Html->link(__d('common', 'Configure'), array('action' => 'edit', $item[$model]['id']), array('class' => 'btn')); },
'30_delete' => function($View, $item, $model) { return $View->Html->link(__d('common', 'delete'), array('action' => 'delete', $item[$model]['id']), array('class' => 'btn')); }
)
), array(
'plugin' => 'SharedPlugin'
));
change in CRUD/index.ctp :
if(is_callable($settings)) {
$entry = call_user_func($settings, $this, $item, $model, $baseUrl);
} else if (strstr($column, '.')) {// If dot notation
$entry = Set::extract($column, $item);
} else {
$entry = $item[$model][$column];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment