Skip to content

Instantly share code, notes, and snippets.

@hmic
Created June 6, 2017 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hmic/98059450bac2b8dbb396b87d39e4ec4e to your computer and use it in GitHub Desktop.
Save hmic/98059450bac2b8dbb396b87d39e4ec4e to your computer and use it in GitHub Desktop.
Adding blacklist actions to related entites für FoC/CrudView
In your controller action set it up like that:
$action->config('scaffold.relations_actions_blacklist', [
'Registrations' => ['edit', 'delete'], // only allow view action
'Rewards' => ['delete'], // don't allow delete
]);
Change/add this in the appropriate place in the Template/Element/view/relations/has_many.ctp which you have copied from the CrudView plugin to your own src/ dir:
foreach (${$viewVar}->{$details['entities']} as ${$otherSingularVar}) :
.
.
.
<td class="actions">
<?php $actions_blacklist = \Cake\Utility\Hash::get($actionConfig, 'scaffold.relations_actions_blacklist.' . $alias); ?>
<?= $blacklist && in_array('view', $actions_blacklist) ? '' : $this->Html->link(__d('crud', 'View'), array('plugin' => $details['plugin'], 'controller' => $details['controller'], 'action' => 'view', ${$otherSingularVar}[$details['primaryKey']])); ?>
<?= $blacklist && in_array('edit', $actions_blacklist) ? '' : $this->Html->link(__d('crud', 'Edit'), array('plugin' => $details['plugin'], 'controller' => $details['controller'], 'action' => 'edit', ${$otherSingularVar}[$details['primaryKey']])); ?>
<?= $blacklist && in_array('delete', $actions_blacklist) ? '' : $this->Html->link(__d('crud', 'Delete'), array('plugin' => $details['plugin'], 'controller' => $details['controller'], 'action' => 'delete', ${$otherSingularVar}[$details['primaryKey']])); ?>
</td>
.
.
.
endforeach;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment