Skip to content

Commit

Permalink
Add example of custom controller action (#207)
Browse files Browse the repository at this point in the history
Add example of custom controller action

Refs #206
  • Loading branch information
hmic authored and ADmad committed Sep 2, 2017
1 parent 6ff3b0b commit 7a53156
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/customizing-templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,35 @@ title for any of the fields by using the ``scaffold.fields`` configuration
// The rest of the fields to display here
]);
Adding Controller Actions to utilize Crud Actions
-------------------------------------------------

It's easy to add an action to a controller that makes use of another
*CrudView* action.

This does use the template provided by the edit action:

.. code-block:: php
public function account() {
$this->Crud->mapAction('account', [
'className' => 'Crud.Edit',
'view' => 'edit',
]);
return $this->Crud->execute(null, $this->Auth->user('id'));
}
By default, it can be overwritten by providing a custom ``register.ctp``:

.. code-block:: php
public function register() {
$this->Crud->mapAction('register', [
'className' => 'Crud.Add',
]);
return $this->Crud->execute();
}
Overriding Template Elements
----------------------------

Expand Down

0 comments on commit 7a53156

Please sign in to comment.