Jonline
Jonline

Reputation: 1747

Cakephp 2.3: How to send an array of data to another controller function for rendering?

I have a controller action that is supposed to collect some preliminary information prior to user registration (head's up, I haven't hooked up auth yet, no one bug out on security plz!) and then redirect to the appropriate controller action, but I can't figure out how to pass an entire array of data. It's possible that I'm just too tired and I'm going to wake up to a facepalm here, but if anyone can set me straight I'd appreciate it.

public function register() {
        if ($this->request->is('post')) {
            if ($this->request->url == "users/register") {
                $data = $this->request->data('Registration');
                switch($data['UserType']) {
                    case "student_reg":
                    /* I've tried this, and it feels right.. do have I to stop autorender or something? */
                        $this->studentReg($data);
                    break;
                    case "educator_reg":
                    /* and this: */
                        $this->redirect(array("action" => "educatorReg", "params" => $data));
                    break;
                    /* ... and so on.... */
                }
            }
        }
        $this->loadModel("Account");
        $accounts = $this->Account->find( 'all');
        $provinces = Hash::combine($accounts, '{n}.Account.province_id', '{n}.Province.name');
        $this->set(compact('accounts','provinces'));
    }

public function studentReg($data) {// and so forth

Upvotes: 0

Views: 2101

Answers (1)

Erebus
Erebus

Reputation: 2038

If you just do return $this->studentReg($data); you should be fine. Cake shouldn't render another view if one has already been rendered.

Upvotes: 1

Related Questions