dpp80346 2015-09-15 12:21
浏览 49

如何使用zend framework 1.11中的表单在复选框中设置数据库中的数据

I have a one table name is task_master. I want to set all record into check box dynamically in zend. I see so many examples but i didn't found anything to fix it.

Task master

id  name<br>
1   Index<br>
2   Add<br>
3   Edit<br>
4   delete<br>

i have new in zend. have any suggestion about it. how can i set data from database in check box using form in zend.

like following.

read from database and create list of check box in view.

enter image description here

  • 写回答

1条回答 默认 最新

  • duanfu5239 2015-09-16 05:07
    关注

    I am not able to make out much from the code that you have shared but this might be able to help you.

    IN YOUR FORM:

    class YourForm extends Zend_Form
    {
        public function init()
        {
    
           $taskMasterCnt = getCountofRowsFromTaskMaster();
    
           for($i = 0; $i <= $taskMasterCnt; $i++){
               $checkBoxes[] = new Zend_Form_Element_Checkbox('checkBox_' . $i);
           }
           $this->addElements($checkBoxes);
      }
    }
    

    IN YOUR HTML:

    <div class="checkbox">
       <?= $this->form->getElement('checkBox_0') ?> <span>Index</span>
    </div>
    <div class="checkbox">
       <?= $this->form->getElement('checkBox_1') ?> <span>Add</span>
    </div>
    

    and so on...

    评论

报告相同问题?

悬赏问题

  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离