Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the 'on' key isn't specified for the validation rule, or it is set to null, the rule will be applied for both create and update operations, as specified in both the <a href="http://book.cakephp.org/1.3/en/view/1145/One-Rule-Per-Field#on-1149" rel="nofollow">1.3</a> and <a href="http://book.cakephp.org/2.0/en/models/data-validation.html#on" rel="nofollow">2.0</a> manual:</p> <blockquote> <p>The ‘on’ key can be set to either one of the following values: ‘update’ or ‘create’. This provides a mechanism that allows a certain rule to be applied either during the creation of a new record, or during update of a record.</p> <p>If a rule has defined ‘on’ => ‘create’, the rule will only be enforced during the creation of a new record. Likewise, if it is defined as ‘on’ => ‘update’, it will only be enforced during the updating of a record.</p> <p>The default value for ‘on’ is null. When ‘on’ is null, the rule will be enforced during both creation and update.</p> </blockquote> <p>The code you have supplied should validate on the edit form as well, as long as you are making sure to include the ID of the logged in user on the form. So for example:</p> <pre><code>&lt;?php echo $this-&gt;Form-&gt;create('User'); ?&gt; &lt;?php echo $this-&gt;Form-&gt;hidden('id', array('value' =&gt; AuthComponent::user('id'))); ?&gt; &lt;?php echo $this-&gt;Form-&gt;input('username'); ?&gt; &lt;?php echo $this-&gt;Form-&gt;end('Update Username'); ?&gt; </code></pre> <p>If the form is a create user form, you wouldn't include the hidden ID field.</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. VO
      singulars
      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