久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

      <legend id='mszTN'><style id='mszTN'><dir id='mszTN'><q id='mszTN'></q></dir></style></legend><tfoot id='mszTN'></tfoot>

        Zend Framework 表單、裝飾器和驗證:我應該回到純

        Zend Framework forms, decorators and validation: should I go back to plain HTML?(Zend Framework 表單、裝飾器和驗證:我應該回到純 HTML 嗎?)
                <legend id='hCexX'><style id='hCexX'><dir id='hCexX'><q id='hCexX'></q></dir></style></legend>

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

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

                  本文介紹了Zend Framework 表單、裝飾器和驗證:我應該回到純 HTML 嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我目前正在開發一個包含大量表單的大型應用程序.

                  I am currently working on a pretty large application which contains a lot of forms.

                  到目前為止,我一直在手工編寫表單并編寫自己的驗證邏輯,但我決定是時候開始使用 Zend_Form 了,它是內置的驗證例程.

                  Up to this moment, I have always been writing my forms by hand and writing my own validation logic, but I have decided it was about time I started using Zend_Form and it's built-in validation routines.

                  然而,我不斷遇到越來越多關于(缺乏)靈活性的問題Zend_Form_Decorator.向單個輸入元素添加額外按鈕等簡單任務變得異常困難.

                  However, I keep stumbling upon more and more problems concerning the (lack of) flexibility caused Zend_Form_Decorator. Simple tasks like adding an extra button to a single input-element become incredibly difficult tasks.

                  我現在已經到了認真考慮放棄 <代碼>Zend_Form_Element + Zend_Form_Decorator 方法完全,但我不想失去優秀的驗證選項.

                  I have now reached a point where I am seriously considering dropping the Zend_Form_Element + Zend_Form_Decorator approach entirely, but I do not want to lose the excellent validation options.

                  基本上,我想要兩全其美:

                  • 以最終用戶看到的方式編寫表單:使用純 HTML
                  • 輕松地向表單字段添加服務器端驗證,而不會破壞太多 ZF 標準行為

                  我正在考慮的一個可能的解決方案是在服務器端編寫表單,就像在視圖中一樣.這將使我能夠輕松地驗證我自己的表單,但(在我看來相當大的)缺點是每個表單都應該定義兩次,這感覺完全錯誤.

                  A possible solution I am considering is writing the forms both on the server side as in the views. This would allow me to easily validate my own forms, but the (in my eyes quite big) downside is that each form should be defined twice, which just feels plain wrong.

                  是否有任何指導方針可以做到這一點?有沒有人遇到過同樣的情況,如果有,你是如何解決這些問題的?

                  Are there any guidelines to do this? Have any of you experienced the same, and if so, how have you solved these issues?

                  我非常想聽聽您的觀點.

                  I'd very much like to hear your points of view.

                  推薦答案

                  我也發現默認裝飾器是一個巨大的痛苦.我理解為什么他們是這樣的,但我認為不便因素"被嚴重低估了.

                  I too find the default decorators to be a massive pain. I understand why they are the way they are, but I think the 'inconvenience factor' has been grossly underestimated.

                  無論如何,我建議使用 用于您的表單的 ViewScripts.請注意,這些與 View 不同——相反,ViewScript 在您的 Form 類中被顯式引用,充當各種子視圖"并允許您控制每個元素的布局.過去很難找到如何使用 ViewScript 的示例,但我會嘗試提供一些有用的東西.

                  Anyway, I would recommend using ViewScripts for your forms. Note that these are not the same as Views -- instead, ViewScripts are referenced explicitly in your Form class, act as a "sub-view" of sorts and allow you to control the layout of each and every element. Examples how to use ViewScripts have been somewhat hard to find in the past, but I'll try to take a stab at providing something useful.

                  首先,在你的表單類中覆蓋 loadDefaultDecorators:

                  First, override loadDefaultDecorators in your form class:

                  public function loadDefaultDecorators() {
                       $this->setDecorators(
                           array(
                               array('ViewScript', 
                                   array('viewScript' => 'foo/bar.phtml')
                               )
                            )
                        );        
                  } 
                  

                  這將引用位于 /views/scripts/foo 中的名為 bar.phtml 的 ViewScript.請注意上面ViewScript"和viewScript"中區分大小寫的差異.

                  This will reference a ViewScript named bar.phtml located in /views/scripts/foo. Note the case-sensitive differences in "ViewScript" and "viewScript" above.

                  接下來,您必須調整應用于每個元素的裝飾器以確保它顯示但沒有煩人的 dt/dd 包裝器.例如:

                  Next, you'll have to tweak the decorators applied to each element to ensure it displays but without the annoying dt/dd wrappers. For instance:

                  $baz = new Zend_Form_Element_Text('bazInput');
                  $baz->setDecorators(array('ViewHelper','Errors')); 
                  

                  最后,您需要構建您的 ViewScript,例如:

                  Finally, you'll need to build your ViewScript, such as:

                  <form method="post" action="<?php echo $this-element->getAction() ?>">
                      <table>
                          <tr>
                              <td><label for="bazInput">Baz:</label></td>
                              <td><?php echo $this->element->bazInput ?></td>
                          </tr>
                      </table>
                      <input type="submit" value="Submit Form" />
                  </form>
                  

                  顯然這是一個非常簡單的例子,但它說明了如何引用表單元素和表單動作.

                  Obviously this is a very simple example, but it illustrates how to reference the form elements and form action.

                  然后在您的視圖中,像往常一樣簡單地引用和輸出您的表單.通過這種方式,您可以更好地控制表單布局——包括輕松添加 Javascript.

                  Then in your View, simply reference and output your form as usual. This way you can have much finer control over your form layouts -- to include easily adding Javascript.

                  我相信這種方法可以解決您的兩個需求:您可以使用純 HTML 構建表單,并且仍然可以利用 Zend 表單驗證機制.

                  I believe this approach resolves both your requirements: you can build forms in plain HTML and still take advantage of the Zend Form validation mechanism.

                  這篇關于Zend Framework 表單、裝飾器和驗證:我應該回到純 HTML 嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                          <tbody id='jl4G8'></tbody>
                          <bdo id='jl4G8'></bdo><ul id='jl4G8'></ul>

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

                          • <i id='jl4G8'><tr id='jl4G8'><dt id='jl4G8'><q id='jl4G8'><span id='jl4G8'><b id='jl4G8'><form id='jl4G8'><ins id='jl4G8'></ins><ul id='jl4G8'></ul><sub id='jl4G8'></sub></form><legend id='jl4G8'></legend><bdo id='jl4G8'><pre id='jl4G8'><center id='jl4G8'></center></pre></bdo></b><th id='jl4G8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='jl4G8'><tfoot id='jl4G8'></tfoot><dl id='jl4G8'><fieldset id='jl4G8'></fieldset></dl></div>
                          • <tfoot id='jl4G8'></tfoot>
                            <legend id='jl4G8'><style id='jl4G8'><dir id='jl4G8'><q id='jl4G8'></q></dir></style></legend>
                            主站蜘蛛池模板: 国产精彩视频在线观看 | 一区二区三区av | 国产一区二区三区在线看 | 婷婷激情五月网 | 欧美一级片在线观看 | 日韩免费福利视频 | 亚洲一区在线免费观看 | 日韩电影免费在线观看中文字幕 | 国产激情视频在线观看 | 国产一区二区免费 | 超碰国产在线 | 亚洲一区二区三区福利 | 久久国产精品色av免费观看 | 成人免费毛片片v | 五月天婷婷狠狠 | 国产精品久久久久久久免费大片 | 激情五月婷婷综合 | 国产欧美一级二级三级在线视频 | 一本岛道一二三不卡区 | 成人在线观看免费 | 北条麻妃99精品青青久久 | 国产欧美在线观看 | 中文一区 | 五月天综合网 | av在线视 | 久久99久久99精品免视看婷婷 | 亚洲一区欧美 | 欧美二区三区 | 狠狠躁天天躁夜夜躁婷婷老牛影视 | 久久久久久久久久久爱 | 亚洲一区二区视频在线播放 | 精品国产青草久久久久福利 | 麻豆视频国产在线观看 | 中文字幕在线视频免费观看 | 久久久久久综合 | 日韩成人一区二区 | 久久精品综合 | 女朋友的闺蜜3韩国三级 | 欧美国产日韩精品 | 国产综合av | 国产精品久久久久久吹潮 |