如何修复我的占位符未显示在表单 Codeigniter 中

我想添加placeholder我的输入。但我正在使用form_helperfrom Codeigniter.


当我被添加时,placeholder没有出现在我的输入表单中。


错误在哪里,在我的代码中还是其他什么地方?


我使用的是框架Codeigniter与Bootstrap


<?php echo form_open_multipart('subscode');?> 


                <div class="form-group">

                    <label for="code" class="col-sm-3 control-label">Code:</label>

                    <div class="col-sm-12">

                        <?php echo form_input('inputcode','','class=form-control','','placeholder=Input your code..');?>

                    </div>

                </div>


阿波罗的战车
浏览 119回答 3
3回答

慕丝7291255

您应该将输入属性编写为数组,如下所示:<?php echo form_open_multipart('subscode');?>&nbsp;&nbsp; &nbsp; <div class="form-group">&nbsp; &nbsp; &nbsp; &nbsp; <label for="code" class="col-sm-3 control-label">Code:</label>&nbsp; &nbsp; &nbsp; &nbsp; <div class="col-sm-12">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <?php echo form_input('inputcode','', ['class'=>'form-control','placeholder'=>'Input your code..']);?>&nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; </div>

红颜莎娜

你能传递一个包含你希望表单包含的数据的关联数组吗?喜欢<?php&nbsp;&nbsp; &nbsp;$data = array(&nbsp; &nbsp; 'name'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; => 'inputcode',&nbsp; &nbsp; 'class'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=> 'form-control',&nbsp; &nbsp; 'placeholder'&nbsp; &nbsp; &nbsp;=> 'put your placeholder',&nbsp; &nbsp; 'size'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; => '50', //if necessary&nbsp; &nbsp; 'style'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=> 'width:50%' //if necessary&nbsp; &nbsp;);&nbsp; &nbsp;echo form_input($data);?>

万千封印

在占位符中添加“”<?php echo form_open_multipart('subscode');?>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="form-group">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <label for="code" class="col-sm-3 control-label">Code:</label>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="col-sm-12">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <?php echo form_input('inputcode','','class="form-control"','','placeholder="Input your code.."');?>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>...?>或添加到数组中:$data = array(&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'name'&nbsp; &nbsp; &nbsp; &nbsp; => 'inputcode',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'id'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; => 'inputcodeid',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'value'&nbsp; &nbsp; &nbsp; &nbsp;=> 'test value',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'placeholder'&nbsp; &nbsp;=> 'placeholder here',&nbsp; );echo form_input($data);
打开App,查看更多内容
随时随地看视频慕课网APP