Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Zend framework Zend_表单显示来自DB表行的表单_Zend Framework_Zend Form_Zend Db - Fatal编程技术网

Zend framework Zend_表单显示来自DB表行的表单

Zend framework Zend_表单显示来自DB表行的表单,zend-framework,zend-form,zend-db,Zend Framework,Zend Form,Zend Db,我想根据DB表记录构建一个动态表单 这是一个房间预订模块 酒店有多个房间类型和描述。 预订酒店时,用户应看到如下表格: -- firstname [text-input] -- lastname [text-input] -- check-in [text-input and datepicker] -- check-out [text-input and datepicker] -- Room1 Title:Room Description [Text-in

我想根据DB表记录构建一个动态表单

这是一个房间预订模块

酒店有多个房间类型和描述。 预订酒店时,用户应看到如下表格:

   -- firstname [text-input]
   -- lastname  [text-input]
   -- check-in  [text-input and datepicker]
   -- check-out [text-input and datepicker]
   -- Room1 Title:Room Description  [Text-input form for number of rooms]
   -- Room2 Title:Room Description  [Text-input form for number of rooms]
   -- Room3 Title:Room Description  [Text-input form for number of rooms]
   -- Room4 Title:Room Description  [Text-input form for number of rooms]
我把这个房间的记录放在桌子上。 我如何用ZEND_表单构建它? 我认为它应该像每个房间里的物品一样

我还想添加自动计算。 每个房间每晚都有特定的价格。 我想把房间的数量加起来,再乘以晚上的数量

那么,我如何使用Zend_表单实现它呢? 我应该添加一些助手吗?新类型的文本元素

如果是,请提供一些指南来源以及如何使用示例


提前谢谢你。

我也有类似的东西,但有复选框,这是一个改编,我希望它能有所帮助

class Form_Booking extends Zend_Form {
   function init() 
   {
       $this->addElement('text', 'first_name', array (
           'label' => 'First name',
           'required' => true 
       ));

       // ... all the other fields

       $count = 1000; // I used this value because I had a strange bug
       //$rooms = array() the entries from your table
       foreach ($rooms as $one) 
       {    
           $this->addElement('checkbox', "$count", array (
              'label'          => $one['room_title'],
              'description'    => $one['room_description'], 
              'belongsTo'      => 'rooms',
       ));
           $count++;
      }
   }
}

我需要在表单中获取一个get变量,以便在init()函数中从DB生成SELECT。如何从indexController.php将该hotel_id传递到froms.php中?用于介绍如何将变量传递到zend表单。