表单复选框和标签与CakePHP和Bootstrap [英] Form checkbox and label with CakePHP and Bootstrap
问题描述
我遇到一些问题,尝试使用CakePHP和Twitter Bootstrap获取复选框输入和标签来输出正确的HTML。
I'm having some issues trying to get checkbox inputs and labels to output the correct HTML using CakePHP and Twitter Bootstrap.
Bootstrap特定的输出应该是: / p>
The Bootstrap specific output should be:
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox"> Keep me logged in
</label>
</div>
</div>
< ),这个Cake形式的输入:
However, using the inputDefaults mentioned here (http://stackoverflow.com/a/9496242/1247225), this Cake form input:
echo $form->input('auto_login', array(
'type' => 'checkbox',
'label' => __('Keep me logged in', true)));
输出:
<div class="control-group">
<input type="hidden" name="data[User][auto_login]" id="UserAutoLogin_" value="0" />
<input type="checkbox" name="data[User][auto_login]" class="" value="1" id="UserAutoLogin" />
<div class="controls">
<label for="UserAutoLogin">Keep me logged in</label>
</div>
</div>
任何想法如何调整这个单独的输入,使其输出正确的Bootstrap HTML,
Any ideas how to adjust this individual input so it outputs the correct Bootstrap HTML, like above?
推荐答案
控制表单输出或输出格式的最好方法是传递一个format参数。尝试玩此:
The best way to control the form output, or the format of the output, is by passing a 'format' argument. Try playing with this:
'format' => array('before', 'label', 'input', 'between', 'after', 'error')
我不认为这是文档,但通过阅读代码,你可以找到它在那里。
I don't think it is document, but by reading the code, you can find it in there.
这篇关于表单复选框和标签与CakePHP和Bootstrap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!