Note that there are some explanatory texts on larger screens.

plurals
  1. POCakePHP validation, error messages in Auth and disabling modified.
    text
    copied!<p>I have tried to get this function working in the desired way but not having much luck. The good news is, is that it works. Only thing I wanted to get working correctly is the field validation error messages which I managed to, but could not login in even if the username and password were correct. I have rolled back the function in the hope that someone could shed some light on this for me please.</p> <pre><code> function login() { $this-&gt;layout = 'login'; $this-&gt;set('title_for_layout', 'Login'); if (!empty($this-&gt;data) &amp;&amp; $id = $this-&gt;Auth-&gt;user('id')) { $this-&gt;User-&gt;id = $id; $this-&gt;User-&gt;saveField('last_login', date('Y-m-d H:i:s')); $this-&gt;Session-&gt;setFlash(__('You have successfully logged in', true)); $this-&gt;redirect(array('action'=&gt;'index')); } } </code></pre> <p>The validation which I have setup in the users model:</p> <pre><code>var $validate = array( 'username' =&gt; array( ), 'login' =&gt; array( 'rule' =&gt; 'isUnique', 'message' =&gt; 'This username has already been taken', ), 'pattern' =&gt; array( 'rule' =&gt; array('custom','/[a-zA-Z0-9\_\-]{6,}$/i'), 'message' =&gt; 'Must be 6 characters or longer with no spaces', ), 'length' =&gt; array( 'rule' =&gt; array('maxLength', 15), 'message' =&gt; 'Please keep username under 15 characters', ), 'notempty' =&gt; array( 'rule' =&gt; array('notempty'), 'message' =&gt; 'Username cannot be empty', ), ), 'password' =&gt; array( 'notempty' =&gt; array( 'rule' =&gt; array('notempty'), 'message' =&gt; 'Password cannot be empty', ), 'length' =&gt; array( 'rule' =&gt; array('between', 5, 15), 'message' =&gt; 'Passwords must be between 5 and 15 characters long with no spaces', 'on' =&gt; 'create', ) ) ); </code></pre> <p>I shall unset certain validation rules for the login, I for now would just like to get the validation actually working in the correct manner.</p> <p>Really, I have three questions...</p> <ol> <li><p>Why is my validation not working correctly?</p></li> <li><p>How can I display messages from the <code>AuthComponent</code> in my views?</p></li> <li><p>How can I temporarily disable the <code>modified</code> field in my table from updating?</p></li> </ol> <p>Many thanks!</p>
 

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