Hola buenas , tarde, estoy siguiendo unos video de zend , y bueno no me muestra el form, y no se porque , uso Netbean
Pero no muestra el formulario.
os pongo como estan mis archivos.
Código PHP:
<?php
class AuthenticationController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// action body
}
public function loginAction()
{
// action body
$form = new Form_LoginForm();
$this->view->form = $form;
$authAdapter = $this->getAuthAdapter();
$username = 'pepe';
$password = 'pepe';
$authAdapter->setIdentity($username)
->setCredential($password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if($result->isValid())
{
$identity = $authAdapter->getResultRowObject();
$authStorange = $auth->getStorage();
$authStorange->write($identity);
//$this->_redirect('index/index');
}
else {
echo 'invalid';
}
}
public function logoutAction()
{
// action body
}
private function getAuthAdapter()
{
$authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
$authAdapter->setTableName('users')
->setIdentityColumn('username')
->setCredentialColumn('password');
return $authAdapter;
}
}
Código PHP:
class Form_LoginForm extends Zend_Form{
public function __construct($option = null)
{
parent::__construct($option);
$this->setName('login');
$username = new Zend_Form_Element_Text('username');
$username->setLabel('User Name:')
->setRequired(true);
$password = new Zend_Form_Element_Password('password');
$password->setLabel('Password:')
->setRequired(true);
$login = new Zend_Form_Element_Submit('login');
$login->setLabel('Login');
$this->addElements(array($username,$password,$login));
$this->setMethod('post');
$this->setAction('/authentication/login');
}
}
este es el login.phtml
[PHP]<?php
$this->form;
[/PHP]
Muchas gracias por la ayuda y un saludo