CakePHP 2xのリダイレクト(redirect)の指定方法

CakePHPでは処理のあとにredirectメソッドを設定して終わるのがセオリー。リダイレクトの後にexit()が発行されるため、処理が終了するそうな。
その飛び先指定方法には3種類がある。

コントローラ・アクション・パラメータを指定

// リダイレクト先:/posts/detail/1
$this->redirect(['controller'=>'posts','action'=>'detail',1]);

URL指定

// リダイレクト先: http://example/posts/detail
$this->redirect('http://example/posts/detail');

URL絶対パス指定

// リダイレクト先: /posts/detail
$this->redirect('/posts/detail');

今回やったこと

今回は、editで編集したら、一覧indexではなく、そのエントリーの詳細detailに戻る、という動きをしたかったので、こんな感じになりました。

$this->redirect(['controller'=>'posts','action'=>'detail',$postID]);
参照ページ
【CakePHP】リダイレクト
https://qiita.com/kazu56/items/08f4772d6fa92304b40b

広告

About: dacelo


2 thoughts on “CakePHP 2xのリダイレクト(redirect)の指定方法”

  1. Immerse yourself in the world of cutting-edge technology with the global version of the POCO M6 Pro, which combines advanced features, stylish design, and an affordable price. This smartphone is designed for those who value speed, quality, and reliability.

    Why is the POCO M6 Pro your ideal choice?

    – Powerful Processor: The octa-core Helio G99-Ultra delivers lightning-fast performance. Gaming, streaming, multitasking—everything runs smoothly and without lag.

    – Stunning Display: The 6.67-inch AMOLED screen with FHD+ resolution (2400×1080) and a 120Hz refresh rate offers incredibly sharp and vibrant visuals. With a touch sampling rate of 2160 Hz, every touch is ultra-responsive.

    – More Memory, More Possibilities: Choose between the 8/256 GB or 12/512 GB configurations to store all your files, photos, videos, and apps without compromise.

    – Professional Camera: The 64 MP main camera with optical image stabilization (OIS), along with additional 8 MP and 2 MP modules, allows you to capture stunning photos in any conditions. The 16 MP front camera is perfect for selfies and video calls.

    – Long Battery Life, Fast Charging: The 5000 mAh battery ensures all-day usage, while the powerful 67W turbo charging brings your device back to life in just a few minutes.

    – Global Version: Support for multiple languages, Google Play, and all necessary network standards (4G/3G/2G) makes this smartphone universal for use anywhere in the world.

    – Convenience and Security: The built-in fingerprint sensor and AI-powered face unlock provide quick and reliable access to your device.

    – Additional Features: NFC, IR blaster, dual speakers, and IP54 splash resistance—everything you need for a comfortable experience.

    The POCO M6 Pro is not just a smartphone; it’s your reliable companion in the world of technology.

    Hurry and grab it at a special price of just 15,000 rubles! Treat yourself to a device that impresses with its power, style, and functionality.

    Take a step into the future today—purchase it on [url=https://ify.ac/1Y26]AliExpress[/url]!

  2. INCREDIBLY REALISTIC SEX DOLL WITH METAL SKELETON!
    Feel the difference – just like a real partner!

    ULTRA-SOFT SKIN that perfectly mimics the touch of real human skin – indistinguishable!
    Anatomically accurate proportions, just like a real woman – every curve in perfect harmony!

    WHY IS THIS DOLL EVERY MAN’S DREAM?
    – FLEXIBLE METAL FRAME – holds any position you can imagine!
    – 100% SAFE – non-toxic medical-grade material, certified by CCIC – no weird smells, just pure pleasure!
    – MAXIMUM VERSATILITY – enjoy vaginal, anal, oral, breast play and anything else you desire!
    – EASY MAINTENANCE – simple to keep clean and fresh!

    EXCLUSIVE OFFER! Get yours now at the best price – while stocks last [url=https://ify.ac/1c3Z]TOP-RATED Love Doll on AliExpress with RAVING REVIEWS![/url]!

    GET YOUR LUXURIOUS COMPANION NOW!

    Discreet neutral packaging – 100% privacy guaranteed!

    This isn’t just a doll – it’s the fulfillment of your deepest desires! Don’t miss out – **order now and experience ultimate pleasure!

Leave a Reply

Your email address will not be published. Required fields are marked *