Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can put a custom class on the field by adding <code>'class' =&gt; 'name'</code> to the array and CakePHP will put that class on the input.</p> <pre><code>echo $form-&gt;input( 'terms', array( 'type' =&gt; 'checkbox', 'class' =&gt; 'some-class-name', 'label' =&gt; 'I have read and accept the &lt;a target="_blank" href="/terms"&gt;Terms&lt;/a&gt;.' )); </code></pre> <p>Produces:</p> <pre><code>&lt;div class="input checkbox"&gt; &lt;input type="hidden" name="" id="" value="0"&gt; &lt;input type="checkbox" name="" class="some-class-name" value="1" id=""&gt; &lt;label for=""&gt;I have read and accept the &lt;a target="_blank" href="/terms"&gt;Terms&lt;/a&gt;.&lt;/label&gt; &lt;/div&gt; </code></pre> <p>You can apply custom styles to the input using <code>'style' =&gt; 'some:style;'</code></p> <pre><code>echo $form-&gt;input( 'terms', array( 'type' =&gt; 'checkbox', 'style' =&gt; 'width:200px;', 'label' =&gt; 'I have read and accept the &lt;a target="_blank" href="/terms"&gt;Terms&lt;/a&gt;.' )); </code></pre> <p>Produces:</p> <pre><code>&lt;div class="input checkbox"&gt; &lt;input type="hidden" name="" id="" value="0"&gt; &lt;input type="checkbox" name="" style="width:200px;" value="1" id=""&gt; &lt;label for=""&gt;I have read and accept the &lt;a target="_blank" href="/terms"&gt;Terms&lt;/a&gt;.&lt;/label&gt; &lt;/div&gt; </code></pre> <p>You can also apply custom styles or classes on the <code>&lt;div&gt;</code> the input is grouped into and to the <code>&lt;label&gt;</code> associated with the <code>&lt;input&gt;</code> as well.</p> <pre><code>echo $form-&gt;input( 'terms', array( 'type' =&gt; 'checkbox', 'label' =&gt; array( 'text' =&gt; 'I have read and accept the &lt;a target="_blank" href="/terms"&gt;Terms&lt;/a&gt;.', 'style' =&gt; 'width:200px;', 'class' =&gt; 'class-for-label' ), 'div' =&gt; array( 'style' =&gt; 'width:200px;', 'class' =&gt; 'class-for-div' ) )); </code></pre> <p>Produces:</p> <pre><code>&lt;div class="class-for-div" style="width:200px;"&gt; &lt;input type="hidden" name="" id="" value="0"&gt; &lt;input type="checkbox" name="" value="1" id=""&gt; &lt;label for="" style="width:200px;" class="class-for-label"&gt;I have read and accept the &lt;a target="_blank" href="/terms"&gt;Terms&lt;/a&gt;.&lt;/label&gt; &lt;/div&gt; </code></pre> <p>And finally, as @dave suggested, you can remove the <code>&lt;div&gt;</code> or <code>&lt;label&gt;</code> by setting them to <code>false</code> and insert your own custom HTML.</p> <pre><code>echo '&lt;div class="input checkbox"&gt;'; echo $form-&gt;input( 'terms', array( 'type' =&gt; 'checkbox', 'label' =&gt; false, 'div' =&gt; false )); echo '&lt;label&gt;I have read and accept the &lt;a target="_blank" href="/terms"&gt;Terms&lt;/a&gt;.&lt;/label&gt;'; echo '&lt;/div&gt;'; </code></pre> <p>Produces:</p> <pre><code>&lt;div class="input checkbox"&gt; &lt;input type="hidden" name="" id="" value="0"&gt; &lt;input type="checkbox" name="" value="1" id=""&gt; &lt;label&gt;I have read and accept the &lt;a target="_blank" href="/terms"&gt;Terms&lt;/a&gt;.&lt;/label&gt; &lt;/div&gt; </code></pre> <p><a href="http://book.cakephp.org/1.3/en/The-Manual/Core-Helpers/Form.html" rel="nofollow">source documentation</a></p> <p>(I've deleted some element attributes because they are specific to the database, tables and models used)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload