免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
php – zf2,表單集合沒(méi)有在zf2中創(chuàng)建正確的輸入名稱

我正在嘗試創(chuàng)建,用于顏色輸入字段的html集合..這將使用javascript動(dòng)態(tài)添加

我的ColorFieldset代碼是

namespace Dashboard\Form;use Zend\Form\Fieldset;use Zend\InputFilter\InputFilterProviderInterface;class ColorFieldset extends Fieldset implements InputFilterProviderInterface{    public function __construct()    {        parent::__construct('color');        $this->add(array(            'name' => 'hash',            'options' => array(                'label' => 'Color'            ),            'attributes' => array(                'required' => 'required',                'class'   => 'input-mini'            )        ));    }    /**     * @return array     \*/    public function getInputFilterSpecification()    {        return array(            'hash' => array(                'required' => true,            )        );    }}

并將其添加到表單中

$this->add(array(    'type' => 'Zend\Form\Element\Collection',    'name' => 'colors',    'options' => array(        'count' => 2 ,        'should_create_template' => true,        'allow_add' => true,        'target_element' => array(            'type' => 'Dashboard\Form\ColorFieldset'        )    )));

并在我的視圖文件.. colors.phtml

<div id="colors_container" class="">     <?php  echo $this->formCollection( $form->get('colors')); ?></div>

它的打印輸出就像

<div class="" id="colors_container">   <label><span>Color</span><input type="text" value="" class="input-mini" required="required" name="hash"></label>   <label><span>Color</span><input type="text" value="" class="input-mini" required="required" name="hash"></label>   <span data-template='<label><span>Color</span><input name="hash" required="required" class="input-mini" type="text" value=""></label>'></span></div>

它應(yīng)該打印像…在zf2 manual 2.0解釋

<div class="" id="colors_container">   <label><span>Color</span><input type="text" value="" class="input-mini" required="required" name="colors[0][hash]"></label>   <label><span>Color</span><input type="text" value="" class="input-mini" required="required" name="colors[1][hash]"></label>   <span data-template='<label><span>Color</span><input name="colors[__index__][hash]" required="required" class="input-mini" type="text" value=""></label>'></span></div>

我希望html輸入名稱為顏色[__ index __] [hash].但它打印名稱為< input type =“text”value =“”class =“input-mini”required =“required”name =“hash”> .

在上面的例子中.我只會(huì)在post $_POST [‘hash’]中獲得一個(gè)顏色名稱.

為什么zf2不打印< input type =“text”value =“”class =“input-mini”required =“required”name =“colors [0] [hash]”> ?請(qǐng)告訴我的代碼有什么問(wèn)題.

解決方法:

哦,我終于找到了答案.我得打電話

$form->prepare();

在視圖中渲染任何內(nèi)容之前.現(xiàn)在它有效

來(lái)源:https://www.icode9.com/content-1-337601.html
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Web Service 使用
jQuery:1.5.3,表單驗(yàn)證(父級(jí)(parent)層次追加(apped))
bootstrap 模態(tài)框 傳值
轉(zhuǎn)貼:jquery.validate全攻略
jQuery Validate驗(yàn)證框架詳解
jQuery驗(yàn)證控件jquery.validate.js使用說(shuō)明 中文API
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服