Created
June 6, 2017 13:26
-
-
Save hmic/98059450bac2b8dbb396b87d39e4ec4e to your computer and use it in GitHub Desktop.
Adding blacklist actions to related entites für FoC/CrudView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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