0

目标:收集一些基本的预注册信息以获取正确的视图,并管理其他一些细节。

问题:我似乎无法将任何东西传递给预期的方法;如果我什么都不通过,则else条件评估并发生重定向。但是,如果$preReg通过了,无论它包含什么,我都无法摆脱这个错误:

无效用户错误:请求的地址

'/myAppName/users/registerUser/userType%26amp%3B7%26amp%3B3%26amp%3B1%26amp%3B5%26amp%3B%26amp%3B%26amp%3B'

在这个服务器上没找到。

这是初始方法:

public function register() {
            if ($this->request->is('post')) {
                if ($this->request->url == "users/register") {
                    $this->redirect("registerUser/".urlencode(implode("&",$this->request->data('Registration'))));
                }
            }
                 // various other logic
}

这应该将一些完全不敏感但有用的信息传递给同一控制器的另一个方法:

public function registerUser($preReg = null) {
        if ($preReg) {
            $data = explode("&",urldecode($preReg));
            $this->view($preReg['UserType']);
            $groups = $this->User->Group->find('all', array('conditions' => array("name =".strtolower(substr($preReg['UserType'], -4)))));
            $this->set(compact($groups, $data));
        } else {
            $this->Session->setFlash("A few details are required before registration can begin. Please fill out the form below.");
            $this->redirect("register");
        }
    }

就目前而言,这个视图就是这么简单:

<h1>THIS IS HOW I KNOW I GOT HERE</h1>
<?php pr($this->request);?>

我很想了解为什么会发生这种情况以及我做错了什么,尤其是在我的想法方面。任何人?

4

1 回答 1

0

Turns out I'm just a nub; this is the standard error message when Cake cannot resolve a URL. In the case above, the registerUser() method wasn't completing properly; $this->view() isn't the proper way to set a view (should have been using a call to $this->render($preReg['UserType']. My broken controller logic created a circumstance where Cake's internal logic wasn't able to resolve my URL consequent to my accidental attempt at interfering with it.

于 2013-10-31T17:04:20.133 回答