How to pass simple data from controller to view in cakePHP
Asked Answered
O

1

7

I get an int value to the controller and I would like to send it to the according view, but i am either passing or accesing it wrong. Here is what I am trying to do:

Controller:

function send($int = NULL) {
    $this->set('integer', $int);

}

View:

echo $integer['int']

Your help is much appreciated!

Ommatophore answered 10/1, 2013 at 9:41 Comment(0)
C
13

Change

echo $integer['int']

To:

echo $integer;

The first parameter in $this->set is used as the variable name in your view, the second parameter is the value assigned to that variable.

Cudgel answered 10/1, 2013 at 9:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.