【问题标题】:Form Input Tag-Bind Input TextBox inside the DIv generated by $form->input()+cakephp$form->input()+cakephp生成的DIv里面的Form Input Tag-Bind Input TextBox
【发布时间】:2009-07-15 10:20:25
【问题描述】:

我正在使用 CakePHP 表单创建器


echo $form->input($r['Attribute']['label'], array('id'=>$r['Attribute']['id'],'name'=>$r['Attribute']['label'],'type'=>'text','style' => 'width:30px'));

echo $form->input($r['Attribute']['label'], array('label'=>false,'div' => false,'id'=>$r['Attribute']['id'].'-','name'=>$r['Attribute']['label'],'type'=>'text','style' => 'width:30px'));

它创建了一个输入框,生成的Html就像

 <div class="input text">
   <label for="6">Mobile Number</label>
   <input type="text" value="" style="width: 30px;" id="6" name="Mobile Number"/>
</div>
<input type="text" value="" style="width: 30px;" id="6-" name="Mobile Number"/>

但我需要第二个输入文本框出现在上面的 Div 中..请建议我。

【问题讨论】:

    标签: cakephp


    【解决方案1】:
    <div class="input text">
        <?php
        echo $form->input($r['Attribute']['label'], array('id'=>$r['Attribute']['id'],'name'=>$r['Attribute']['label'],'type'=>'text','style' => 'width:30px', 'div' => false));
        echo $form->input($r['Attribute']['label'], array('label'=>false,'div' => false,'id'=>$r['Attribute']['id'].'-','name'=>$r['Attribute']['label'],'type'=>'text','style' => 'width:30px'));
        ?>
    </div>
    

    请注意,我也在第一个输入中添加了'div' =&gt; false

    但这不会给你两个同名的输入吗?

    【讨论】:

    • 我已经创建了你所说的我如何才能检索其全部价值?我正在使用 $_POST 检索我的 Cakephp 控制器中的值
    • 慈悲,如果您使用的是 $_POST,您甚至没有阅读基本的蛋糕教程。你应该使用 $this->data。在编写真正的应用程序之前,至少阅读基本的博客教程 (book.cakephp.org/view/219/Blog)。
    • foreach ($_POST as $key => $value): if(is_array($value)){ $value = implode('', $_POST[$key]); $this->data['Result']['value']=$value; }else{ $this->data['Result']['value']=$value; } $this->data['Result']['form_id']=$formid; $this->data['Result']['label']=Inflector::humanize($key); $this->Form->submitForm($this->data);结束;我已经使用了上面并得到了它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-18
    • 2020-04-23
    • 2013-04-26
    • 2016-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多