Skip to content

Bake controller action add => view #1035

Open
@dereuromark

Description

@dereuromark

Description

I often end up in 90% of the cases to adjust the default redirect from index to the view.
As after creating the record, you usually want to interact with it right away, or see the details on it with links to follow up on.

Index: templates/bake/element/Controller/add.twig
<+>UTF-8
===================================================================
diff --git a/templates/bake/element/Controller/add.twig b/templates/bake/element/Controller/add.twig
@@ -30,7 +30,7 @@
             if ($this->{{ currentModelName }}->save(${{ singularName }})) {
                 $this->Flash->success(__('The {{ singularHumanName|lower }} has been saved.'));
 
-                return $this->redirect(['action' => 'index']);
+                return $this->redirect(['action' => 'view', ${{ singularName }}->id]);
             }
             $this->Flash->error(__('The {{ singularHumanName|lower }} could not be saved. Please, try again.'));
         }

Would it make sense to adjust the bake templates here?
What do others think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions