pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    • <bdo id='kCU6I'></bdo><ul id='kCU6I'></ul>

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

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

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

    1. 如何刪除 Zend 表單元素上的所有 DtDdWrappers 和標(biāo)簽

      How To Remove All DtDdWrappers and Labels on Zend Form Elements(如何刪除 Zend 表單元素上的所有 DtDdWrappers 和標(biāo)簽)

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

    2. <i id='dMtE5'><tr id='dMtE5'><dt id='dMtE5'><q id='dMtE5'><span id='dMtE5'><b id='dMtE5'><form id='dMtE5'><ins id='dMtE5'></ins><ul id='dMtE5'></ul><sub id='dMtE5'></sub></form><legend id='dMtE5'></legend><bdo id='dMtE5'><pre id='dMtE5'><center id='dMtE5'></center></pre></bdo></b><th id='dMtE5'></th></span></q></dt></tr></i><div class="7l7nvdv" id='dMtE5'><tfoot id='dMtE5'></tfoot><dl id='dMtE5'><fieldset id='dMtE5'></fieldset></dl></div>
        <bdo id='dMtE5'></bdo><ul id='dMtE5'></ul>

          <tfoot id='dMtE5'></tfoot>

                  <tbody id='dMtE5'></tbody>

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

                本文介紹了如何刪除 Zend 表單元素上的所有 DtDdWrappers 和標(biāo)簽的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我知道我可以像這樣從每個元素中單獨刪除額外的東西

                I know I can remove the extra stuff from each element individually like so

                $button ->removeDecorator('DtDdWrapper')
                        ->removeDecorator('HtmlTag')
                     ->removeDecorator('Label');
                

                我想知道我是否可以以 zend 形式為我的所有元素實現(xiàn)相同的效果?
                以及如何刪除包裝表單的 dl?

                I was wondering if I can achieve the same for all my elements in a zend form?
                And how does one remove the dl wrapping the form?

                推薦答案

                Markus,這是我使用的一個解決方案,看起來效果很好,希望它適合你.

                Markus, here is a solution that I use that seems to work well, hopefully it will be suitable for you.

                首先,為了渲染沒有

                標(biāo)簽的表單,我們需要在表單對象本身上設(shè)置裝飾器.從擴(kuò)展 Zend_Form 的類內(nèi)部,您將調(diào)用 Zend_Form->setDecorators() 傳遞表單裝飾器數(shù)組.

                First, in order to render the form with no <dl> tag, we need to set the decorators on form object itself. From inside a class extending Zend_Form, you would call Zend_Form->setDecorators() passing an array of form decorators.

                來自參考指南:

                Zend_Form 的默認(rèn)裝飾器是 FormElements、HtmlTag(包裝在定義列表中)和 Form;創(chuàng)建它們的等效代碼如下:

                  $form->setDecorators(array(
                      'FormElements',
                      array('HtmlTag', array('tag' => 'dl')),
                      'Form'
                  ));
                

                要將表單包裝在 dl 以外的其他東西中,我們使用上述裝飾器,但將 dl 更改為您使用的任何標(biāo)記,我通常使用 form 類的 div> 我們稍后會看到.

                To wrap the form in something other than a dl, we use the above decorators but change the dl to whatever tag you use, I typically use a div of class form which we will see later.

                接下來,需要處理的元素.Zend_Form 元素對不同類型的元素有不同的裝飾器.以下各組元素類型都有自己獨特的裝飾器集:[Submit &按鈕]、[驗證碼]、[文件]、[圖像]和[收音機*].radio 的裝飾器與標(biāo)準(zhǔn)元素非常相似,只是它沒有在標(biāo)簽內(nèi)指定 for 屬性.

                Next, the elements need to be dealt with. Zend_Form elements have different decorators for different types of elements. The following groups of element types each have their own distinct set of decorators: [Submit & Button], [Captcha], [File], [Image], and [Radio*]. The decorator for radio is very similar to standard elements except that it does not specify the for attribute inside the label.

                所有其他表單元素、文本、密碼、選擇、復(fù)選框等都使用相同的默認(rèn)裝飾器集.

                All other form elements, text, password, select, checkbox, etc use the same set of default decorators.

                要從單個表單元素中刪除 dd/dt 標(biāo)簽,我們需要對其應(yīng)用我們自己的一組裝飾器.下面是一個不使用 dd/dt 標(biāo)簽的例子:

                To remove the dd/dt tags from an individual form element we would need to apply our own set of decorators to it. Here is an example that does not use dd/dt tags:

                array(
                    'ViewHelper',
                    'Errors',
                    array('Description', array('tag' => 'p', 'class' => 'description')),
                    array('HtmlTag',     array('class' => 'form-div')),
                    array('Label',       array('class' => 'form-label'))
                );
                

                這會將每個表單元素包裝在一個帶有 form-div 類的 div 標(biāo)簽中.問題是,您必須將這組裝飾器應(yīng)用于您不想包含在 dd/dt 標(biāo)簽中的每個元素,這可能會有點問題.

                This will wrap each form element in a div tag with the class form-div. The problem is, you have to apply this set of decorators to EVERY element that you don't want to be wrapped in the dd/dt tags which can be a bit problematic.

                為了解決這個問題,我創(chuàng)建了一個從 Zend_Form 擴(kuò)展的類,并賦予它一些與 Zend_Form 的默認(rèn)裝飾器不同的默認(rèn)行為和裝飾器.

                To solve this issue, I create a class that extends from Zend_Form and give it some default behavior and decorators that are different from the default decorators for Zend_Form.

                雖然我們不能讓 Zend_Form 自動將正確的裝飾器分配給特定的元素類型(您可以將它們分配給特定的元素名稱),但我們可以設(shè)置一個默認(rèn)值,并讓我們自己輕松訪問一個地方的裝飾器,所以如果他們需要改變,他們可以很容易地改變所有形式.

                While we can't quite have Zend_Form automatically assign the correct decorators to specific element types (you can assign them to specific element names), we can set a default, and give ourselves easy access to the decorators from one place, so if they need to change, they can be easily changed for all forms.

                這是基類:

                <?php
                
                class Application_Form_Base extends Zend_Form
                {
                    /** @var array Decorators to use for standard form elements */
                    // these will be applied to our text, password, select, checkbox and radio elements by default
                    public $elementDecorators = array(
                        'ViewHelper',
                        'Errors',
                        array('Description', array('tag' => 'p', 'class' => 'description')),
                        array('HtmlTag',     array('class' => 'form-div')),
                        array('Label',       array('class' => 'form-label', 'requiredSuffix' => '*'))
                    );
                
                    /** @var array Decorators for File input elements */
                    // these will be used for file elements
                    public $fileDecorators = array(
                        'File',
                        'Errors',
                        array('Description', array('tag' => 'p', 'class' => 'description')),
                        array('HtmlTag',     array('class' => 'form-div')),
                        array('Label',       array('class' => 'form-label', 'requiredSuffix' => '*'))
                    );
                
                    /** @var array Decorator to use for standard for elements except do not wrap in HtmlTag */
                    // this array gets set up in the constructor 
                    // this can be used if you do not want an element wrapped in a div tag at all
                    public $elementDecoratorsNoTag = array();
                
                    /** @var array Decorators for button and submit elements */
                    // decorators that will be used for submit and button elements
                    public $buttonDecorators = array(
                        'ViewHelper',
                        array('HtmlTag', array('tag' => 'div', 'class' => 'form-button'))
                    );
                
                
                    public function __construct()
                    {
                        // first set up the $elementDecoratorsNoTag decorator, this is a copy of our regular element decorators, but do not get wrapped in a div tag
                        foreach($this->elementDecorators as $decorator) {
                            if (is_array($decorator) && $decorator[0] == 'HtmlTag') {
                                continue; // skip copying this value to the decorator
                            }
                            $this->elementDecoratorsNoTag[] = $decorator;
                        }
                
                        // set the decorator for the form itself, this wraps the <form> elements in a div tag instead of a dl tag 
                        $this->setDecorators(array(
                                             'FormElements',
                                             array('HtmlTag', array('tag' => 'div', 'class' => 'form')),
                                             'Form'));
                
                        // set the default decorators to our element decorators, any elements added to the form
                        // will use these decorators
                        $this->setElementDecorators($this->elementDecorators);
                
                        parent::__construct();
                        // parent::__construct must be called last because it calls $form->init()
                        // and anything after it is not executed
                    }
                }
                
                /*
                   Zend_Form_Element default decorators:
                   $this->addDecorator('ViewHelper')
                        ->addDecorator('Errors')
                        ->addDecorator('Description', array('tag' => 'p', 'class' => 'description'))
                        ->addDecorator('HtmlTag', array('tag' => 'dd',
                                                        'id'  => array('callback' => $getId)))
                        ->addDecorator('Label', array('tag' => 'dt'));
                */
                

                現(xiàn)在要使用這個類,從這個基類擴(kuò)展所有的表單,然后像往常一樣分配元素.如果您使用 Zend_Form_Element_XXX 而不是 addElement() 那么您將需要將裝飾器之一作為選項傳遞給元素構(gòu)造函數(shù),如果您使用 Zend_Form->addElement,然后它將使用我們在類中分配的默認(rèn)裝飾器 $elementDecorators.

                Now to use the class, extend all of your forms from this base class and go about assigning elements as usual. If you use Zend_Form_Element_XXX as opposed to addElement() then you will need to pass one of the decorators as an option to the element constructor, if you use Zend_Form->addElement, then it will use the default decorator $elementDecorators we assigned in the class.

                這是一個示例,展示了如何從該類進(jìn)行擴(kuò)展:

                Here is an example that shows how to extend from that class:

                <?php
                
                class Application_Form_Test extends Application_Form_Base
                {
                    public function init()
                    {
                        // Add a text element, this will automatically use Application_Form_Base->elementDecorators for its decorators
                        $this->addElement('text', 'username', array(
                            'label'      => 'User Name:',
                            'required'   => false,
                            'filters'    => array('StringTrim'),
                        ));
                
                        // This will not use the correct decorators unless we specify them directly
                        $text2 = new Zend_Form_Element_Text(
                            'text2',
                            array(
                                'decorators' => $this->elementDecorators, // must give the right decorator
                                'label' => 'Text 2'
                            )
                        );
                
                        $this->addElement($text2);
                
                        // add another element, this also uses $elementDecorators
                        $this->addElement('text', 'email', array(
                            'label'      => 'Email:', 
                            'required'   => false,
                            'filters'    => array('StringTrim', 'StringToLower'), 
                        ));
                
                        // add a submit button, we don't want to use $elementDecorators, so pass the button decorators instead
                        $this->addElement('submit', 'submit', array(
                            'label' => 'Continue', 
                            'decorators' => $this->buttonDecorators // specify the button decorators
                        ));
                    }
                }
                

                這顯示了一種非常有效的方法來擺脫 dd/dt 和 dl 元素并將它們替換為您自己的元素.必須為每個元素指定裝飾器有點不方便,而不是能夠為特定元素分配裝飾器,但這似乎工作得很好.

                This shows a pretty effective way to get rid of the dd/dt and dl elements and replace them with your own. It is a bit inconvenient to have to specify the decorators for every element, as opposed to being able to assign decorators to specific elements, but this seems to work well.

                再添加一個我認(rèn)為您想要做的解決方案,如果您想渲染一個沒有標(biāo)簽的元素,只需創(chuàng)建一個新的裝飾器并像這樣省略標(biāo)簽裝飾器:

                To add one more solution that I think you were looking to do, if you would like to render an element with no label, simply create a new decorator and omit the label decorator from it like this:

                $elementDecorators = array(
                    'ViewHelper',
                    'Errors',
                    array('Description', array('tag' => 'p', 'class' => 'description')),
                    array('HtmlTag',     array('class' => 'form-div')),
                    // array('Label',       array('class' => 'form-label', 'requiredSuffix' => '*'))
                    // comment out or remove the Label decorator from the element in question
                    // you can do the same for any of the decorators if you don't want them rendered
                );
                

                請隨時要求澄清任何事情,希望這能幫助您.

                Feel free to ask for clarification on anything, hopefully this will help you out.

                這篇關(guān)于如何刪除 Zend 表單元素上的所有 DtDdWrappers 和標(biāo)簽的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

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

                <tfoot id='po1q7'></tfoot>
                  <bdo id='po1q7'></bdo><ul id='po1q7'></ul>
                  1. <legend id='po1q7'><style id='po1q7'><dir id='po1q7'><q id='po1q7'></q></dir></style></legend>
                      <tbody id='po1q7'></tbody>

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

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

                        • 主站蜘蛛池模板: 国际学校_国际学校哪个好_国际课程学校-国际学校择校网 | 餐饮加盟网_特色餐饮加盟店_餐饮连锁店加盟 | 线材成型机,线材折弯机,线材成型机厂家,贝朗自动化设备有限公司1 | 上海新光明泵业制造有限公司-电动隔膜泵,气动隔膜泵,卧式|立式离心泵厂家 | 微型驱动系统解决方案-深圳市兆威机电股份有限公司 | 中央空调维修、中央空调保养、螺杆压缩机维修-苏州东菱空调 | 多米诺-多米诺世界纪录团队-多米诺世界-多米诺团队培训-多米诺公关活动-多米诺创意广告-多米诺大型表演-多米诺专业赛事 | 护腰带生产厂家_磁石_医用_热压护腰_登山护膝_背姿矫正带_保健护具_医疗护具-衡水港盛 | 哈希PC1R1A,哈希CA9300,哈希SC4500-上海鑫嵩实业有限公司 | 飞歌臭氧发生器厂家_水处理臭氧发生器_十大臭氧消毒机品牌 | 河南生物显微镜,全自动冰冻切片机-河南荣程联合科技有限公司 | 大_小鼠elisa试剂盒-植物_人Elisa试剂盒-PCR荧光定量试剂盒-上海一研生物科技有限公司 | 层流手术室净化装修-检验科ICU改造施工-华锐净化工程-特殊科室建设厂家 | 圈酒招商网【jiushuitv.com】_酒水招商_代理_加盟平台 | 英国公司注册-新加坡公司注册-香港公司开户-离岸公司账户-杭州商标注册-杭州优创企业 | 喷码机,激光喷码打码机,鸡蛋打码机,手持打码机,自动喷码机,一物一码防伪溯源-恒欣瑞达有限公司 | 防腐储罐_塑料储罐_PE储罐厂家_淄博富邦滚塑防腐设备科技有限公司 | 深圳美安可自动化设备有限公司,喷码机,定制喷码机,二维码喷码机,深圳喷码机,纸箱喷码机,东莞喷码机 UV喷码机,日期喷码机,鸡蛋喷码机,管芯喷码机,管内壁喷码机,喷码机厂家 | 红外光谱仪维修_二手红外光谱仪_红外压片机_红外附件-天津博精仪器 | 五轴加工中心_数控加工中心_铝型材加工中心-罗威斯 | 广州番禺搬家公司_天河黄埔搬家公司_企业工厂搬迁_日式搬家_广州搬家公司_厚道搬迁搬家公司 | 东莞爱加真空科技有限公司-进口真空镀膜机|真空镀膜设备|Polycold维修厂家 | 广西资质代办_建筑资质代办_南宁资质代办理_新办、增项、升级-正明集团 | 塑料异型材_PVC异型材_封边条生产厂家_PC灯罩_防撞扶手_医院扶手价格_东莞市怡美塑胶制品有限公司 | 制丸机,小型中药制丸机,全自动制丸机价格-甘肃恒跃制药设备有限公司 | 知企服务-企业综合服务(ZiKeys.com)-品优低价、种类齐全、过程管理透明、速度快捷高效、放心服务,知企专家! | 气动隔膜阀_气动隔膜阀厂家_卫生级隔膜阀价格_浙江浙控阀门有限公司 | 十二星座查询(性格特点分析、星座运势解读) - 玄米星座网 | 电动球阀_不锈钢电动球阀_电动三通球阀_电动调节球阀_上海湖泉阀门有限公司 | 商用绞肉机-熟肉切片机-冻肉切丁机-猪肉开条机 - 广州市正盈机械设备有限公司 | 科研ELISA试剂盒,酶联免疫检测试剂盒,昆虫_植物ELISA酶免试剂盒-上海仁捷生物科技有限公司 | 西点培训学校_法式西点培训班_西点师培训_西点蛋糕培训-广州烘趣西点烘焙培训学院 | 加热制冷恒温循环器-加热制冷循环油浴-杭州庚雨仪器有限公司 | 老城街小面官网_正宗重庆小面加盟技术培训_特色面馆加盟|牛肉拉面|招商加盟代理费用多少钱 | 自动部分收集器,进口无油隔膜真空泵,SPME固相微萃取头-上海楚定分析仪器有限公司 | 打包箱房_集成房屋-山东佳一集成房屋有限公司 | 河南空气能热水器-洛阳空气能采暖-洛阳太阳能热水工程-洛阳润达高科空气能商行 | 玻璃钢型材-玻璃钢风管-玻璃钢管道,生产厂家-[江苏欧升玻璃钢制造有限公司] | 烽火安全网_加密软件、神盾软件官网 | 南京PVC快速门厂家南京快速卷帘门_南京pvc快速门_世界500强企业国内供应商_南京美高门业 | 威客电竞(vk·game)·电子竞技赛事官网 |