开发者

calling zend form to AuthenticationController error

开发者 https://www.devze.com 2023-01-26 01:37 出处:网络
this is my form script: located in application/forms and i copy it form here and by the way im using xampp

this is my form script: located in application/forms and i copy it form here and by the way im using 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.////

}

and this my authentication script.. located in application/controller:

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(开发者_StackOverflow中文版$password);

       }

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

     return $myDb;
    }

}

i want to call the class form Form_LoginForm inside the AuthenticationController but it gives me and error: *Fatal error: Class 'Form_LoginForm' not found in C:\xampp\htdocs\zendframework\sampleSite\application\controllers\AuthenticationController.php on line 18* my question is what is the right way to call a class forms.. and where is the __autoload located?


Try changing class Form_LoginForm extends Zend_Form into class Application_Form_LoginFrom extends Zend_Form and then in you're AuthController $form = new Application_Form_LoginForm

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号