<tfoot id='eecDT'></tfoot>

  • <i id='eecDT'><tr id='eecDT'><dt id='eecDT'><q id='eecDT'><span id='eecDT'><b id='eecDT'><form id='eecDT'><ins id='eecDT'></ins><ul id='eecDT'></ul><sub id='eecDT'></sub></form><legend id='eecDT'></legend><bdo id='eecDT'><pre id='eecDT'><center id='eecDT'></center></pre></bdo></b><th id='eecDT'></th></span></q></dt></tr></i><div id='eecDT'><tfoot id='eecDT'></tfoot><dl id='eecDT'><fieldset id='eecDT'></fieldset></dl></div>

    1. <small id='eecDT'></small><noframes id='eecDT'>

        <bdo id='eecDT'></bdo><ul id='eecDT'></ul>
        <legend id='eecDT'><style id='eecDT'><dir id='eecDT'><q id='eecDT'></q></dir></style></legend>

        yii 中的多模型表单

        multi model forms in yii(yii 中的多模型表单)
          • <bdo id='MC5jV'></bdo><ul id='MC5jV'></ul>
              <tbody id='MC5jV'></tbody>
            <i id='MC5jV'><tr id='MC5jV'><dt id='MC5jV'><q id='MC5jV'><span id='MC5jV'><b id='MC5jV'><form id='MC5jV'><ins id='MC5jV'></ins><ul id='MC5jV'></ul><sub id='MC5jV'></sub></form><legend id='MC5jV'></legend><bdo id='MC5jV'><pre id='MC5jV'><center id='MC5jV'></center></pre></bdo></b><th id='MC5jV'></th></span></q></dt></tr></i><div id='MC5jV'><tfoot id='MC5jV'></tfoot><dl id='MC5jV'><fieldset id='MC5jV'></fieldset></dl></div>
              <tfoot id='MC5jV'></tfoot>

              <small id='MC5jV'></small><noframes id='MC5jV'>

                • <legend id='MC5jV'><style id='MC5jV'><dir id='MC5jV'><q id='MC5jV'></q></dir></style></legend>
                  本文介绍了yii 中的多模型表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何在 Yii 中创建多模型表单?我搜索了 Yii 的整个文档,但没有得到有趣的结果.有人可以给我一些方向或想法吗?任何帮助都将是可观的.

                  How to create a multi-model form in Yii? I searched the entire documentation of Yii, but got no interesting results. Can some one give me some direction or thoughts about that? Any help will be appreciable.

                  推荐答案

                  在我的经验中,我得到了这个解决方案并且很快就能理解

                  In my expirience i got this solution to work and quickly understandable

                  对于要收集的数据,您有两个模型.假设 PersonVehicle.

                  You have two models for data you wish collect. Let's say Person and Vehicle.

                  在您的控制器中创建模型对象:

                  In your controller create model objects:

                  public function actionCreate() {
                  
                    $Person = new Person;
                    $Vehicle = new Vehicle;
                  
                    //.. see step nr.3
                  
                    $this->render('create',array(
                          'Person'=>$Person,
                          'Vehicle'=>$Vehicle)
                    );
                  }
                  

                  第 2 步:编写视图文件

                  //..define form
                  echo CHtml::activeTextField($Person,'name');
                  echo CHtml::activeTextField($Person,'address');
                  // other fields..
                  
                  echo CHtml::activeTextField($Vehicle,'type');
                  echo CHtml::activeTextField($Vehicle,'number');
                  
                  //..enter other fields and end form
                  

                  在你的视野中放一些标签和设计;)

                  put some labels and design in your view ;)

                  现在返回到您的控制器并为 POST 操作编写功能

                  and now go back to your controller and write funcionality for POST action

                  if (isset($_POST['Person']) && isset($_POST['Vehicle'])) {
                      $Person = $_POST['Person']; //dont forget to sanitize values
                      $Vehicle = $_POST['Vehicle']; //dont forget to sanitize values
                      /*
                          Do $Person->save() and $Vehicle->save() separately
                          OR
                          use Transaction module to save both (or save none on error) 
                          http://www.yiiframework.com/doc/guide/1.1/en/database.dao#using-transactions
                      */
                  }
                  else {
                      Yii::app()->user->setFlash('error','You must enter both data for Person and Vehicle');
                   // or just skip `else` block and put some form error box in the view file
                  }
                  

                  这篇关于yii 中的多模型表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <tbody id='Zfrcw'></tbody>
                  • <small id='Zfrcw'></small><noframes id='Zfrcw'>

                    • <i id='Zfrcw'><tr id='Zfrcw'><dt id='Zfrcw'><q id='Zfrcw'><span id='Zfrcw'><b id='Zfrcw'><form id='Zfrcw'><ins id='Zfrcw'></ins><ul id='Zfrcw'></ul><sub id='Zfrcw'></sub></form><legend id='Zfrcw'></legend><bdo id='Zfrcw'><pre id='Zfrcw'><center id='Zfrcw'></center></pre></bdo></b><th id='Zfrcw'></th></span></q></dt></tr></i><div id='Zfrcw'><tfoot id='Zfrcw'></tfoot><dl id='Zfrcw'><fieldset id='Zfrcw'></fieldset></dl></div>

                          <bdo id='Zfrcw'></bdo><ul id='Zfrcw'></ul>
                          <tfoot id='Zfrcw'></tfoot>

                            <legend id='Zfrcw'><style id='Zfrcw'><dir id='Zfrcw'><q id='Zfrcw'></q></dir></style></legend>