私はアプリでも同じことをしていますが、フォーム要素のCSSクラスは実際にはかなりよく一致していることがわかりました。
TwitterのBootstrapフォーム要素は次のようになります。
<div class="clearfix">
<label for="xlInput">X-Large input</label>
<div class="input">
<input class="xlarge" id="xlInput" name="xlInput" size="30" type="text" />
</div>
</div>
そして、CakePHPのFormHelperは次のような要素を生成します。
<div class="input text">
<label for="UserName">Name</label>
<input name="data[User][name]" type="text" value="" id="UserName" />
</div>
主な違いは、Bootstrapのdivの外側のラベルです。FormHelperを使用すると、のようなカスタムクラスを設定できますarray('class' => 'clearfix')
。
Bootstrapの.input
クラスはforms.lessmargin-left: 150px;
で定義されており、入力を右に移動するように設定されているだけです。このスタイルを使用しない場合は、代わりに追加することができmargin-right: 20px;
ます<label>
。
私のフォーム要素のコードは次のようになります。
echo $this->Form->input('first_name', array('div' => 'clearfix'));
...そしてBootstrapによって適切にスタイル設定された要素を生成します。
<div class="clearfix required">
<label for="PersonFirstName">First Name</label>
<input name="data[Person][first_name]" maxlength="50" type="text" id="PersonFirstName"/>
</div>
私はまだ両方のフレームワークを学んでいるので、これに問題があるかもしれません。それがお役に立てば幸いです。