我試圖用表單來填充數據庫,用戶可以編輯信息。我添加一個名爲 「數」 的模式:
Number.php:在Zend中編輯表格
<?php
class Model_Number extends Zend_Db_Table_Abstract
{
protected $_name = 'cc_number';
protected $_schema = 'general';
}
在該表(CC_NUMBER),我有三個領域: 「編號,數量,國家」
內應用程序/表格,我添加了這種形式:
EditNumber.php:
<?php
Class Form_EditNumber extends Zend_Form
{
public function __construct($option = null)
{
parent::__construct($option);
$this->setName('edit_number');
$message = new Zend_Form_Element_Text('message');
$message->setLabel(' number :')
->setRequired(true);
$country = new Zend_Form_Element_Text('country');
$country->setLabel(' country name :')
->setRequired(true);
$login = new Zend_Form_Element_Submit('login');
$login ->setLabel('edit ');
$this ->addElements(array($message,$login));
$this->setMethod('post');
}
}
在控制器中,我試圖從URL的最後一部分得到號碼,然後從這個數字得到信息:
數/ editAction:
public function editAction(){
$request = $this->getRequest();
$form_number = new Form_EditNumber();
$uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
$part = basename($uri);
$numberModel = new Model_Number();
$select = $numberModel->fetchRow($numberModel->select()->where("number = '$part'"));
$this->view->edit_form = $form_number->populate($select->toArray());
}