注册表格不起作用

时间:2011-11-02 07:59:55

标签: forms cakephp

我得到了RegisterController.php,其中我得到了:

class RegisterController extends AppController {
    public $name = 'Register';
    public $components = array('Session');

    public function index() {
        if ($this->request->is('account')) {
           // if ($this->Post->save($this->request->data)) {
                echo "got it";
                $this->Session->setFlash('Your post has been saved.');
                $this->redirect(array('action' => 'index'));
           // }
        }
    }
}

我的/View/Register/index.tcp文件:

<?php
    echo $this->Form->create('Account');
    echo $this->Form->input('username');
    echo $this->Form->input('password');
    $options = array(
        'label' => 'Register',
        'class' => 'submit'
    );
    echo $this->Form->end($options);
?>

我的/Model/Account.php文件:

<?php
class Account extends AppModel {
    public $name = 'Account';
    public $validate = array(
        'username' => array(
            'rule' => 'notEmpty'
        ),
        'password' => array(
            'notEmpty' => array(
                'rule' => 'notEmpty',
                'message' => 'Can not be empty.'
            ),
            'minLength' => array(
                'rule' => array('minLength', '8'),
                'message' => 'Min. 8 chars.'
            )
        )
    );
}
?>

问题在于,我点击了提交按钮,没有任何动静。它应该至少检查验证。

错误在哪里?

1 个答案:

答案 0 :(得分:0)

如果在选项中添加操作,则应该有效:

echo $this->Form->create('Account', array('action' => 'your/url'));