PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 19, 2022

[FIXED] Setting global action on cakephp 3.3.5

 March 19, 2022     cakephp, cakephp-3.0     No comments   

Issue

I have a call to action button that opens a form for users to subscribe. I'm trying to have this form on the global header. The action subscribe() is in the App Controller but not sure how to call it from every single view.

I've tried a few things but haven't been able to make it work.

<?= $this->Form->create($subscription, ['controller' => 'App', 'action' => 'subscribe']) ?>

Any ideas? Thanks.


Solution

You could also use a named route.

/config/routes.php

    $routes->connect('/subscribe' , ['controller'=>'App', 'action'=>'subscribe'] , ['_name' => 'subscribe']);

in your view

<?= $this->Form->create('Subscripton', [url => ['_name' => 'subscribe']]); ?>


Answered By - Derek
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing