Note that there are some explanatory texts on larger screens.

plurals
  1. POMissing asterisk in the label of the required field in cakephp
    primarykey
    data
    text
    <p>I have problem with displaying required fields in Cakephp 2.4.2.</p> <p>If I use</p> <pre><code>$this-&gt;Form-&gt;input('username'); </code></pre> <p>in rendered html I have</p> <pre><code>&lt;div class="input text required"&gt; &lt;label for="UserUsername"&gt;Username&lt;/label&gt; &lt;input name="data[User][username]" type="text" id="UserUsername" required="required"/&gt; &lt;/div&gt; </code></pre> <p>and the label has asterisk: username*</p> <p>If I want to use Twitter Bootstrap with its horizontal form style, my input changes to something like this:</p> <pre><code>&lt;div class="form-horizontal"&gt; &lt;div class="form-group"&gt; &lt;label for="username" class="col-xs-3"&gt;&lt;/label&gt; &lt;div class="col-xs-4"&gt; &lt;?php echo $form-&gt;input('username',array('id' =&gt; 'username','label' =&gt; false)); ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>which results in</p> <pre><code>&lt;div class="form-horizontal"&gt; &lt;div class="form-group"&gt; &lt;label for="username" class="col-xs-3"&gt;Username&lt;/label&gt; &lt;div class="col-xs-4"&gt; &lt;div class="input text required"&gt; &lt;input name="data[User][username]" id="username" type="text" required="required"/&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and label lost asterisk: username</p> <p>Basically, if Cake input has option 'label' => false it will have input label without asterisk:</p> <pre><code>$this-&gt;Form-&gt;label('User.username'); $this-&gt;Form-&gt;input('username',array('label' =&gt; false)); </code></pre> <p>results in</p> <pre><code>&lt;label for="UserUsername"&gt;Username&lt;/label&gt; &lt;div class="input text required"&gt; &lt;input name="data[User][username]" type="text" id="UserUsername" required="required"/&gt; &lt;/div&gt; </code></pre> <p>and no asterisk in the label.</p> <p>What would be the way to have asterisk in the label of the required field while using Cake Form Helper?</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.
 

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