调用zend表单来验证AuthenticationController错误

时间:2010-11-22 08:25:30

标签: zend-framework zend-form

这是我的表单脚本:位于应用程序/表单中,我将其复制为here,顺便使用xampp

   class Form_LoginForm extends Zend_Form
{
 public function init()
     {
         $username = $this->addElement('text', 'username', array(
             'filters'    => array('StringTrim', 'StringToLower'),
             'validators' => array(
                 'Alpha',
                 array('StringLength', false, array(3, 20)),
             ),
             'required'   => true,
             'label'      => 'Your username:',
         ));  ect.////

}

这是我的身份验证脚本..位于应用程序/控制器中:

class AuthenticationController extends Zend_Controller_Action {

    public function loginAction()
        {
           $form = new Form_LoginForm(); // doest work
           $this->view->form = $form;

           $myDb = $this->getAuthAdapter();
           $userName = 'user';
           $password = 'ds';

           $myDb->setIdentity($userName)
                ->setCredential($password);

       }

  private function getAuthAdapter(){
     $myDb = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
     $myDb->setTableName('zuser')
          ->setIdentityColumn('table1')
          ->setCredentialColumn('table2');

     return $myDb;
    }

}

我想在AuthenticationController中调用类形式 Form_LoginForm 但是它给了我并且错误:*致命错误:在C:\ xampp \ htdocs \ zendframework \ sampleSite \中找不到类'Form_LoginForm'第18行的application \ controllers \ AuthenticationController.php * 我的问题是什么是调用类表单的正确方法.. __autoload位于何处?

1 个答案:

答案 0 :(得分:1)

尝试将class Form_LoginForm extends Zend_Form更改为class Application_Form_LoginFrom extends Zend_Form,然后将您更改为AuthController $form = new Application_Form_LoginForm