Привет, ребята. Я новичок в ZF1. Я пытаюсь отобразить форму добавления одного сотрудника, поэтому для этого я создал таблицу с именами сотрудников и полями и создал модель и контроллер.
Вот моя модель: (Приложение / модели / DbTable):
<?php
/**
* application/models/DbTable/Employee.php
*/
class Employee extends Zend_Db_Table_Abstract
{
protected $_name = 'employees';
/**
* Our employees' primary key is just 'id'.
* If you have another name to that field just use this line below:
* protected $_primary = 'emp_id';
*/
}
Вот мой контроллер (Приложение / Контроллеры / EmployeesController.php)
<?php
/**
* controllers/PostsController.php
*/
class PostsController extends Zend_Controller_Action
{
public function init() //called always before actions
{
$this->posts= new Posts(); //DbTable
}
public function addAction()
{
$form = $this->getForm(); //getting the post form
$this->view->form =$form; //assigning the form to view
}
public function getForm()
{
$username = new Zend_Form_Element_Text('username');
$username->setLabel('Username')
->setDescription('Just put the username here')
->setRequired(true) // required field
->addValidator('StringLength', false, array(10, 120)) // min 10 max 120
->addFilters(array('StringTrim'));
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Post') // the button's value
->setIgnore(true); // very usefull -> it will be ignored before insertion
$form = new Zend_Form();
$form->addElements(array($username, $firstname, $empid, $submit));
// ->setAction('') // you can set your action. We will let blank, to send the request to the same action
return $form; // return the form
}
}
Вот мой взгляд (Приложение / views / scripts / employee / add.phtml):
<?php echo $this->form;?>
Так что моя проблема здесь в том, что когда я запускаю этот URL в своем браузере http://localhost/zendAuth/application/views/scripts/employee/add.phtml
я не получаю добавление этого сотрудника с
Может ли кто-нибудь помочь мне, какую ошибку я совершил?
Заранее спасибо.