In preceding earlier post, I asked whether putting outside array validation.. I went and try outside of the class model which was not working. Now I learned that Stephen's code is outside of the array validation but inside the class model which makes sense. And it works ! Thanks, man. Hope this can help me in building a fuller ACI component later.
Do you know of any nice beginner chapters for ACI components?--I'm building an admin centre and member centre each has their own CMS. I went briefly on the internet and found it difficult to begin with. I can only move on to intermediate later after I learned exactly what ACI is. Do you have suggestions for both beginner and intermediate (ACI) components ? @Stephen &, Amit, Thank you very much. On Dec 21, 11:59 pm, Stephen <[email protected]> wrote: > Looks to me like the error is to do with the lines before line 60. > > Looking back at Amit's suggestion, the validate array wasn't ended properly > (I think due to it being a impartial example) > > 'confirm_password' => array( > 'notEmpty' => array( > 'rule' => 'notEmpty', > 'message' => 'This field cannot be blank.', > 'last' => true, > ), > 'lengthCheck' => array( > 'rule' => '/^.{6,40}$/', > 'message' => 'Minimum password 6 > characters.', > 'last' => true, > ), > 'confirmed' => array( > 'rule' => 'confirmPassword' > 'message' => 'Both passwords should match.' > ), > ), > > Should be something like this > > var $validate = array( > 'confirm_password' => array( > 'notEmpty' => array( > 'rule' => 'notEmpty', > 'message' => 'This field cannot be blank.', > 'last' => true > ), > 'lengthCheck => array( > 'rule' => '/^.{6,40}$/', > 'message' => 'Minimum password 6 characters.', > 'last' => true > ), > 'confirmed' => array( > 'rule' => 'confirmPassword', > 'message' => 'Both passwords should match.' > ) > ) > ); > > function confirmPassword() { > ... > > } > > Be sure to include any other validation and the function. > > On 21 December 2010 15:12, John Maxim <[email protected]> wrote: > > > Just to repost the error message: > > > Parse error: parse error, expecting `')'' in C:\wamp\www\cakephp\app > > \models\user.php on line 60 > > > On Dec 21, 11:11 pm, John Maxim <[email protected]> wrote: > > > Hi Stephen, > > > > wow it gives exactly the same error. Where it points at line 60 > > > > ==>Line 60 ===> function confirmPassword() { > > > $hash = > > Security::hash($this->data[$this->alias] > > > ['confirm_password'], null, true); > > > > if($this->data[$this->alias]['password'] == > > $hash) { > > > return true; > > > > return false; > > > > } > > > > Same like the previous one. It points at the same line where the > > > function name is... > > > > On Dec 21, 11:01 pm, Stephen <[email protected]> wrote: > > > > >http://api.cakephp.org/view_source/security/#line-113 > > > > > Try something like this maybe? > > > > > function confirmPassword() { > > > > $hash = > > Security::hash($this->data[$this->alias]['confirm_password'], > > > > null, true); > > > > > if($this->data[$this->alias]['password'] == $hash) { > > > > return true; > > > > } > > > > > return false; > > > > > } > > > > > On 21 December 2010 14:51, John Maxim <[email protected]> wrote: > > > > > > I checked many times, based on your explanation here: > > > > > > (($variable) == condition(param1, param2, param3)) > > > > > > Even cleared browser cookies... > > > > > > and it gives exactly the same error. > > > > > > -------------the whole piece of model code: > > > > > class User extends AppModel > > > > > { > > > > > var $name = 'User'; > > > > > > var $validate = array ( > > > > > > 'username' => array( > > > > > 'notEmpty' => array( > > > > > 'rule' => 'notEmpty', > > > > > 'message' => 'This field cannot be > > blank.', > > > > > 'last' => true, > > > > > ), > > > > > 'uniqueCheck' => array( > > > > > 'rule' => 'isUnique', > > > > > 'message' => 'That username has > > already been > > > > > taken.', > > > > > 'last' => true, > > > > > ), > > > > > 'lengthCheck' => array( > > > > > 'rule' => '/^.{6,40}$/', > > > > > 'message' => 'Minimum username 6 > > > > > characters.', > > > > > 'last' => true, > > > > > ), > > > > > ), > > > > > > 'email' => array( > > > > > 'notEmpty' => array( > > > > > 'rule' => 'notEmpty', > > > > > 'message' => 'This field cannot be blank.', > > > > > 'last' => true, > > > > > ), > > > > > 'email' => array( > > > > > 'rule' => 'email', > > > > > 'message' => 'That is not a valid email address.', > > > > > 'last' => true, > > > > > ), > > > > > ), > > > > > > 'confirm_password' => array( > > > > > 'notEmpty' => array( > > > > > 'rule' => 'notEmpty', > > > > > 'message' => 'This field cannot be > > blank.', > > > > > 'last' => true, > > > > > ), > > > > > 'lengthCheck' => array( > > > > > 'rule' => '/^.{6,40}$/', > > > > > 'message' => 'Minimum password 6 > > > > > characters.', > > > > > 'last' => true, > > > > > ), > > > > > 'checkMatch' => array( > > > > > 'rule' => 'confirmPassword', > > > > > 'message' => 'Both passwords should > > match.', > > > > > 'last' => true, > > > > > ), > > > > > > ), > > > > > > function confirmPassword() { > > > > > return (($this->data[$this->alias]['password']) == > > > > > > Security::hash($this->data[$this->alias]['confirm_password'], null, > > > > > true)); > > > > > > } > > > > > > ); > > > > > > } > > > > > > ------------ > > > > > > Just in case I might done wrong else where but I don't think so. See > > > > > somewhere else wrong ? > > > > > > On Dec 21, 10:45 pm, John Maxim <[email protected]> wrote: > > > > > > Yes, the error is the same even using your code and I've checked a > > few > > > > > > times. It gave the same error. > > > > > > > function confirmPassword() { > > > > > > return (($this->data[$this->alias]['password']) == > > > > > > Security::hash($this->data[$this->alias]['confirm_password'], null, > > > > > > true)); > > > > > > > } > > > > > > > On Dec 21, 10:32 pm, Stephen <[email protected]> > > wrote: > > > > > > > > To me it seems the bracket is misplaced. > > > > > > > > You were doing this > > > > > > > > (($variable) == condition(param1), param2, param3) > > > > > > > > The parameters for Security::hash should be contained within the > > > > > brackets. > > > > > > > > (($variable) == condition(param1, param2, param3)) > > > > > > > > Is the error the same? > > > > > > > > On 21 December 2010 14:18, John Maxim <[email protected]> wrote: > > > > > > > > > I crossed replied with your previous message Stephen, sorry, > > > > > > > > > and I tried your code it gave the same error. > > > > > > > > > Thanks for your time, too.. > > > > > > > > > What is your thoughts on this error ? > > > > > > > > > On Dec 21, 10:13 pm, John Maxim <[email protected]> wrote: > > > > > > > > > I tried putting it outside the array validation where it > > gives > > > > > parsing > > > > > > > > > error without the bracket sign "(" > > > > > > > > > > On Dec 21, 9:58 pm, John Maxim <[email protected]> wrote: > > > > > > > > > > > Hi, thanks Amit, but > > > > > > > > > > > I got an error here: > > > > > > > > > > > Parse error: parse error, expecting `')'' in > > > > > C:\wamp\www\cakephp\app > > > > > > > > > > \models\user.php on line 66 > > > > > > > > > > > On line 66 is: > > > > > > > > > > > function confirmPassword() > > > > > > > > > > { > > > > > > > > > > return > > > > > (($this->data[$this->alias]['password']) > > > > > > > > == > > > Security::hash($this->data[$this->alias]['confirm_password']), > > > > > null, > > > > > > > > > > true); > > > > > > > > > > } > > > > > > > > > > > I modified a few times to include and exclude some of the > > > > > brackets, > > > > > > > > > > but it gives the same error as shown above. *I used Amit > > code as > > > > > > > > > > originally and it started with the error above. > > > > > > > > > > > Do I add this function inside the var $validate = array ( > > > > > ); > > > > > > > > > > > or it has to be outside the array validation ? > > > > > > > > > > > Can someone look where the function go wrong ? > > > > > > > > > > > On Dec 21, 5:41 pm, Amit Badkas <[email protected]> > > wrote: > > > > > > > > > > > > Hi, > > > > > > > > > > > > You need to use custom validation method for this in your > > > > > model, > > > > > > > > something > > > > > > > > > > > like > > > > > > > > > > > > 'confirm_password' => array( > > > > > > > > > > > 'notEmpty' => array( > > > > > > > > > > > 'rule' => 'notEmpty', > > > > > > > > > > > 'message' => 'This field > > cannot > > > > > be > > > > > > > > blank.', > > > > > > > > > > > 'last' => true, > > > > > > > > > > > ), > > > > > > > > > > > 'lengthCheck' => array( > > > > > > > > > > > 'rule' => '/^.{6,40}$/', > > > > > > > > > > > 'message' => 'Minimum > > password > > > > > 6 > > > > > > > > > > > characters.', > > > > > > > > > > > 'last' => true, > > > > > > > > > > > ), > > ... > > read more » Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
