Re: Model Validation

2014-07-31 Thread Stephen S
Are you submitting the entire form or individual fields via ajax?

If you're submitting the entire form and returning HTML, make sure to set
your $invalidFields variable which you have and check
if(isset($invalidFields)) in your returned html to highlight the fields. If
you're still not sure please post your ajax code as well as all the
relevant controller code so we can see exactly what you are doing wrong.
Thanks


On 31 July 2014 09:37, Sudhir Pandey  wrote:

> Thanks for your response , but I submitting the form by ajax & then
> validate. I have encode the error & get it on success method of ajax. The
> problem arising  How can I show these error message .
>
> I want model validation using ajax
>
>
> On Wednesday, 30 July 2014 14:59:03 UTC+5:30, Dr. Tarique Sani wrote:
>
>> Start here http://bit.ly/UKovlN
>>
>> If you get stuck with a method you choose ask further questions.
>>
>> Tarique
>>
>>
>> On Wed, Jul 30, 2014 at 2:40 PM, Sudhir Pandey  wrote:
>>
>>> How can I perform cakephp Model validation using ajax & shows error
>>> message.
>>>
>>> I have already set the error message in controller but not shown in view.
>>>
>>> $this->Candidateprofile->set($this->data);
>>> if($this->Candidateprofile->validates())
>>> {
>>> $this->Candidateprofile->create();
>>> if($this->Candidateprofile->saveAll($this->data)) {
>>>  }else{
>>> $invalidFields=$this->Candidateprofile->invalidFields();
>>>  $this->set('invalidFields',$invalidFields);
>>> }
>>> }else{
>>> $invalidFields=$this->Candidateprofile->invalidFields();
>>>  $this->set('invalidFields',$invalidFields);
>>> }
>>>
>>> --
>>> Like Us on FaceBook https://www.facebook.com/CakePHP
>>> Find us on Twitter http://twitter.com/CakePHP
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "CakePHP" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to cake-php+u...@googlegroups.com.
>>> To post to this group, send email to cake...@googlegroups.com.
>>>
>>> Visit this group at http://groups.google.com/group/cake-php.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> =
>> The Conference Schedule Creator : http://shdlr.com
>>
>> PHP for E-Biz : http://sanisoft.com
>> =
>>
>  --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Kind Regards
 Stephen Speakman

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Model Validation

2014-07-31 Thread Sudhir Pandey
Thanks for your response , but I submitting the form by ajax & then 
validate. I have encode the error & get it on success method of ajax. The 
problem arising  How can I show these error message .

I want model validation using ajax 

On Wednesday, 30 July 2014 14:59:03 UTC+5:30, Dr. Tarique Sani wrote:
>
> Start here http://bit.ly/UKovlN
>
> If you get stuck with a method you choose ask further questions.
>
> Tarique
>
>
> On Wed, Jul 30, 2014 at 2:40 PM, Sudhir Pandey  > wrote:
>
>> How can I perform cakephp Model validation using ajax & shows error 
>> message.
>>
>> I have already set the error message in controller but not shown in view.
>>
>> $this->Candidateprofile->set($this->data);
>> if($this->Candidateprofile->validates())
>> {
>> $this->Candidateprofile->create();
>> if($this->Candidateprofile->saveAll($this->data)) {
>>  }else{
>> $invalidFields=$this->Candidateprofile->invalidFields();
>>  $this->set('invalidFields',$invalidFields);
>> }
>> }else{
>> $invalidFields=$this->Candidateprofile->invalidFields();
>>  $this->set('invalidFields',$invalidFields);
>> }
>>
>> -- 
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to cake-php+u...@googlegroups.com .
>> To post to this group, send email to cake...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/cake-php.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> =
> The Conference Schedule Creator : http://shdlr.com
>
> PHP for E-Biz : http://sanisoft.com
> = 
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Model Validation

2014-07-30 Thread Dr. Tarique Sani
Start here http://bit.ly/UKovlN

If you get stuck with a method you choose ask further questions.

Tarique


On Wed, Jul 30, 2014 at 2:40 PM, Sudhir Pandey  wrote:

> How can I perform cakephp Model validation using ajax & shows error
> message.
>
> I have already set the error message in controller but not shown in view.
>
> $this->Candidateprofile->set($this->data);
> if($this->Candidateprofile->validates())
> {
> $this->Candidateprofile->create();
> if($this->Candidateprofile->saveAll($this->data)) {
>  }else{
> $invalidFields=$this->Candidateprofile->invalidFields();
> $this->set('invalidFields',$invalidFields);
> }
> }else{
> $invalidFields=$this->Candidateprofile->invalidFields();
> $this->set('invalidFields',$invalidFields);
> }
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
=
The Conference Schedule Creator : http://shdlr.com

PHP for E-Biz : http://sanisoft.com
=

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Model Validation Error Message

2013-01-21 Thread Igor Padovan da Silva
put key error in input options.

echo $this->Form->input('orgao_id', array('div' => false, 'class' => 
'text-input small-input', 'label' => 'Orgão', 'empty' => 'Selecione', 
'error' => array('wrap'=>'span','class' => 'input-notification error 
png_bg')) );

Em sexta-feira, 18 de janeiro de 2013 19h35min56s UTC-3, Michael escreveu:
>
> So because of how I am dynamically creating my form inputs/save data, the 
> standard rule validation msg isnt being displayed on the input when the 
> save rule returns false. How do I manually trigger the msg to appear on a 
> given input? Thanks
>
>
> ~Michael
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Model Validation Error Message

2013-01-19 Thread jodator
You can:

   - Add a massege by Model::invalidate function or even add a message to 
   validation error messages field (Controller::validationErrors)
   - Add client side validation (there a neat jQuery validation plugin with 
   minimal configuration



On Friday, January 18, 2013 11:35:56 PM UTC+1, Michael wrote:
>
> So because of how I am dynamically creating my form inputs/save data, the 
> standard rule validation msg isnt being displayed on the input when the 
> save rule returns false. How do I manually trigger the msg to appear on a 
> given input? Thanks
>
>
> ~Michael
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Model Validation field names

2012-04-15 Thread lowpass
You could use Cake's translation.

locale/eng/LC_MESSAGES/default.po:

msgid "password_control"
msgstr "Confirm Password"



But I notice you're already using the __() function elsewhere. If
you've already got a multilingual app then this may not be the best
choice (depending on your other field names and whether they appear in
other text messages). If you don't plan to ever make it multilingual,
don't use __() to echo arbitrary text as it'll just slow things down
needlessly.

On Fri, Apr 13, 2012 at 5:06 PM, CyberGlitch  wrote:
> Sort of a unique situation but maybe not? I'm curious if it's possible
> to change the "field" name when being displayed in validationErrors.
> Something that could be set in the model would make the most sense but
> can't seem to find what I'm looking for.
>
> Background. Doing custom flash messages and for bad ones.
>
> $this->set('errors', $this->User->validationErrors);
> $this->Session->setFlash('The user could not be saved. Please, try
> again.','flash_bad');
>
> Then in flash_bad element have.
>
>                                                                                echo $message;
>                                        if (!empty($errors)) { ?>
>                                                
>                                                         are ');?>  php __('error(s) in your submission:'); ?>
>                                                        
>                                                                 ($errors as $field => $error) { ?>
>                                                                 ucfirst($field) .' - '. $error; ?>
>                                                                
>                                                        
>                                                
>                                        
>
> Some of the table field names aren't self explanatory. Easy example in
> doing a password repeat verification.
>
> 2 fields
> password
> password_control
>
> Error message generates
> Password - At least 6 characters
> Password_control - Does not match
>
> So is there a way, again thinking in the model, to set a different
> field name to be shown for the error messages and possibly other
> things.
>
>                'password_control' => array(
>                        'notempty' => array(
>                                'rule' => array('notEmpty'),
>                                'allowEmpty' => false,
>                                'message' => 'Does not match',
> ->                      'displayField' => 'Confirm Password'
>                        )
>
> to then get
> Password - At least 6 characters
> Confirm Password - Does not match
>
> --
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Model validation for multiple actions

2010-09-06 Thread Maurits van der Schee

Hi,

You need to look into the Auth component, validation has nothing to do 
with it.


Validation is about accepting data for save in the database
Authenthication is about finding out who the user is
Authorization is about telling what actions may be executed.

So you want authentication and authorization. Check out the Auth component.

Read about it in the auth component tutorial at:

http://www.jbcrawford.net/archives/45

Regards,

Maurits

On 09/06/2010 11:48 AM, amin wrote:

Hi,

Can u plz help me out, how to call validation for multiple actions of
a controller

E.g. a user controller, in user controller add, signup, forgot
password .. etc are actions

now in model class User extends AppModel{

}

how to validate mentioned actions validation in User model 

I have tried $validate method but it only allow for only one action

so plz help me out.

thnks in advance

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en




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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Model validation for multiple actions

2010-09-06 Thread AD7six


On Sep 6, 11:40 am, amin  wrote:
> Hi,
>
> Can u plz help me out, how to call validation for multiple actions of
> a controller

The action and validation are not dependent - related.

>
> E.g. a user controller, in user controller add, signup, forgot
> password .. etc are actions
>
> now in model class User extends AppModel{
>
> }
>
> how to validate mentioned actions validation in User model 

You don't validate actions, you validate data.

>
> I have tried $validate method but it only allow for only one action

the validate array contains fields, not actions.

>
> so plz help me out.
>
> thnks in advance

AD

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Model validation on unit testing

2009-07-23 Thread jperras

Look up the difference between the 'required' rule and the 'notempty'
rule.

http://book.cakephp.org/view/129/required

-jperras.

On Jun 7, 9:14 am, williamn  wrote:
> Hi all,
>
> I have a simple model like below
>
> class Department extends AppModel {
>
>         var $name = 'Department';
>         var $validate = array(
>                 'code' => array('notempty'),
>                 'name' => array('notempty'),
>                 'abbreviation' => array('notempty'),
>                 'phone_num' => array('notempty')
>         );
>
> }
>
> and create a simple test like this
>
> function testInvalidCreate() {
>         $this->Department->create();
>         $this->assertFalse($this->Department->save());
>
> }
>
> correct me if I'm wrong, $this->Department->save() should return false
> right? but in my case it returning an array.
>
> Any suggestion?
>
> Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Model validation on unit testing

2009-07-22 Thread William Notowidagdo
Thanks. I will try it.

On Wed, Jul 22, 2009 at 4:33 PM, Joe  wrote:

> > 'between' => array(
> > 'rule' => array('between', 1, 5),
> > 'message' => '1 - 5 only'
> > ),
>
> should be (between and range)
>
> > 'between' => array(
> > 'rule' => array('range', 1, 5),
> > 'message' => '1 - 5 only'
> > ),
>
> for williamn's question,
>
> put 'required'=true in the validate rule
> other wise, as nth is provided, and nth is required, it just passed!!
>
> On 7月22日, 下午4時49分, Joe  wrote:
> > model/rating.php
> > class Rating extends AppModel {
> >
> > var $name = 'Rating';
> > var $validate = array(
> > 'score' => array(
> > 'numeric' => array(
> > 'rule' => 'numeric',
> > 'message' => 'numeric score only'
> > ),
> > 'between' => array(
> > 'rule' => array('between', 1, 5),
> > 'message' => '1 - 5 only'
> > ),
> > )
> > );}
> >
> > test/models/rating.test.php:
> > function testScoreRange() {
> > $this->data = array(
> > 'score'  => 10,
> > 'url_id'  => 10,
> > );
> > $this->Rating->create();
> > $this->Rating->set($this->data);
> > $result = $this->Rating->save();
> >
> > $this->assertFalse($result);
> >
> > }
> >
> > On 7月22日, 下午1時57分, Joe  wrote:
> >
> >
> >
> > > same here
> >
> > > On 7月10日, 下午5時03分, williamn  wrote:
> >
> > > > Hi all,
> >
> > > > Did this ever happened to anyone here? :)
> >
> > > > On Jun 7, 8:14 pm, williamn  wrote:
> >
> > > > > Hi all,
> >
> > > > > I have a simple model like below
> >
> > > > > class Department extends AppModel {
> >
> > > > > var $name = 'Department';
> > > > > var $validate = array(
> > > > > 'code' => array('notempty'),
> > > > > 'name' => array('notempty'),
> > > > > 'abbreviation' => array('notempty'),
> > > > > 'phone_num' => array('notempty')
> > > > > );
> >
> > > > > }
> >
> > > > > and create a simpletestlike this
> >
> > > > > function testInvalidCreate() {
> > > > > $this->Department->create();
> > > > > $this->assertFalse($this->Department->save());
> >
> > > > > }
> >
> > > > > correct me if I'm wrong, $this->Department->save() should return
> false
> > > > > right? but in my case it returning an array.
> >
> > > > > Any suggestion?
> >
> > > > > Thanks.
> >
>


-- 
Best Regards,
--William Notowidagdo

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Model validation on unit testing

2009-07-22 Thread Joe
> 'between' => array(
> 'rule' => array('between', 1, 5),
> 'message' => '1 - 5 only'
> ),

should be (between and range)

> 'between' => array(
> 'rule' => array('range', 1, 5),
> 'message' => '1 - 5 only'
> ),

for williamn's question,

put 'required'=true in the validate rule
other wise, as nth is provided, and nth is required, it just passed!!

On 7月22日, 下午4時49分, Joe  wrote:
> model/rating.php
> class Rating extends AppModel {
>
>         var $name = 'Rating';
>         var $validate = array(
>                 'score' => array(
>                         'numeric' => array(
>                     'rule' => 'numeric',
>                     'message' => 'numeric score only'
>                 ),
>                 'between' => array(
>                     'rule' => array('between', 1, 5),
>                     'message' => '1 - 5 only'
>                 ),
>             )
>         );}
>
> test/models/rating.test.php:
>         function testScoreRange() {
>             $this->data = array(
>                         'score'  => 10,
>                         'url_id'  => 10,
>             );
>             $this->Rating->create();
>             $this->Rating->set($this->data);
>             $result = $this->Rating->save();
>
>             $this->assertFalse($result);
>
>         }
>
> On 7月22日, 下午1時57分, Joe  wrote:
>
>
>
> > same here
>
> > On 7月10日, 下午5時03分, williamn  wrote:
>
> > > Hi all,
>
> > > Did this ever happened to anyone here? :)
>
> > > On Jun 7, 8:14 pm, williamn  wrote:
>
> > > > Hi all,
>
> > > > I have a simple model like below
>
> > > > class Department extends AppModel {
>
> > > >         var $name = 'Department';
> > > >         var $validate = array(
> > > >                 'code' => array('notempty'),
> > > >                 'name' => array('notempty'),
> > > >                 'abbreviation' => array('notempty'),
> > > >                 'phone_num' => array('notempty')
> > > >         );
>
> > > > }
>
> > > > and create a simpletestlike this
>
> > > > function testInvalidCreate() {
> > > >         $this->Department->create();
> > > >         $this->assertFalse($this->Department->save());
>
> > > > }
>
> > > > correct me if I'm wrong, $this->Department->save() should return false
> > > > right? but in my case it returning an array.
>
> > > > Any suggestion?
>
> > > > Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Model validation on unit testing

2009-07-22 Thread Joe

model/rating.php
class Rating extends AppModel {

var $name = 'Rating';
var $validate = array(
'score' => array(
'numeric' => array(
'rule' => 'numeric',
'message' => 'numeric score only'
),
'between' => array(
'rule' => array('between', 1, 5),
'message' => '1 - 5 only'
),
)
);
}
test/models/rating.test.php:
function testScoreRange() {
$this->data = array(
'score'  => 10,
'url_id'  => 10,
);
$this->Rating->create();
$this->Rating->set($this->data);
$result = $this->Rating->save();

$this->assertFalse($result);

}

On 7月22日, 下午1時57分, Joe  wrote:
> same here
>
> On 7月10日, 下午5時03分, williamn  wrote:
>
>
>
> > Hi all,
>
> > Did this ever happened to anyone here? :)
>
> > On Jun 7, 8:14 pm, williamn  wrote:
>
> > > Hi all,
>
> > > I have a simple model like below
>
> > > class Department extends AppModel {
>
> > >         var $name = 'Department';
> > >         var $validate = array(
> > >                 'code' => array('notempty'),
> > >                 'name' => array('notempty'),
> > >                 'abbreviation' => array('notempty'),
> > >                 'phone_num' => array('notempty')
> > >         );
>
> > > }
>
> > > and create a simpletestlike this
>
> > > function testInvalidCreate() {
> > >         $this->Department->create();
> > >         $this->assertFalse($this->Department->save());
>
> > > }
>
> > > correct me if I'm wrong, $this->Department->save() should return false
> > > right? but in my case it returning an array.
>
> > > Any suggestion?
>
> > > Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Model validation on unit testing

2009-07-21 Thread Joe

same here

On 7月10日, 下午5時03分, williamn  wrote:
> Hi all,
>
> Did this ever happened to anyone here? :)
>
> On Jun 7, 8:14 pm, williamn  wrote:
>
>
>
> > Hi all,
>
> > I have a simple model like below
>
> > class Department extends AppModel {
>
> >         var $name = 'Department';
> >         var $validate = array(
> >                 'code' => array('notempty'),
> >                 'name' => array('notempty'),
> >                 'abbreviation' => array('notempty'),
> >                 'phone_num' => array('notempty')
> >         );
>
> > }
>
> > and create a simpletestlike this
>
> > function testInvalidCreate() {
> >         $this->Department->create();
> >         $this->assertFalse($this->Department->save());
>
> > }
>
> > correct me if I'm wrong, $this->Department->save() should return false
> > right? but in my case it returning an array.
>
> > Any suggestion?
>
> > Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Model validation on unit testing

2009-07-10 Thread williamn

Hi all,

Did this ever happened to anyone here? :)

On Jun 7, 8:14 pm, williamn  wrote:
> Hi all,
>
> I have a simple model like below
>
> class Department extends AppModel {
>
>         var $name = 'Department';
>         var $validate = array(
>                 'code' => array('notempty'),
>                 'name' => array('notempty'),
>                 'abbreviation' => array('notempty'),
>                 'phone_num' => array('notempty')
>         );
>
> }
>
> and create a simple test like this
>
> function testInvalidCreate() {
>         $this->Department->create();
>         $this->assertFalse($this->Department->save());
>
> }
>
> correct me if I'm wrong, $this->Department->save() should return false
> right? but in my case it returning an array.
>
> Any suggestion?
>
> Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Model Validation -> 'blank' rule triggered without beeing set

2008-11-13 Thread leberle

Thanks :)

@
> btw, your TRUE shouldn't be enclosed in an array, it should be "
> 'required' => true ".

well, i got confused by the warning:
preg_match() [function.preg-match]: Delimiter must not be alphanumeric
or backslash
when i dont had the "required" setting in an array, so i pushed it
into one, and the error disappeard (but i guess the setting didn't
work then). But now i got it, the warning disappeared after adding the
rule.

Everythings fine now, thx :)

On 13 Nov., 10:59, Rafael Bandeira aka rafaelbandeira3
<[EMAIL PROTECTED]> wrote:
> > triggered? And how can i avoid it without changing the cakecore?
>
> set the 'rule' key on $validate for each field, and specify the rule
> you want it to follow, when a validation
> scheme is set on $validate but no rule is specified, the 'blank' rule
> is assumed.
> Please refer to the cookbook for more information on validation, we
> got lots of information there.
> btw, your TRUE shouldn't be enclosed in an array, it should be "
> 'required' => true ".
>
> > $this->exists();
> > What effect does this call have in this context? As far as i see, the
> > call returns a boolean to the void o_O ?
>
> Model::exists() caches the returned value in a private var - Model::
> $__exists - and that's the used in the rest of the method to test the
> record existence.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model Validation -> 'blank' rule triggered without beeing set

2008-11-13 Thread Rafael Bandeira aka rafaelbandeira3


> triggered? And how can i avoid it without changing the cakecore?

set the 'rule' key on $validate for each field, and specify the rule
you want it to follow, when a validation
scheme is set on $validate but no rule is specified, the 'blank' rule
is assumed.
Please refer to the cookbook for more information on validation, we
got lots of information there.
btw, your TRUE shouldn't be enclosed in an array, it should be "
'required' => true ".

> $this->exists();
> What effect does this call have in this context? As far as i see, the
> call returns a boolean to the void o_O ?

Model::exists() caches the returned value in a private var - Model::
$__exists - and that's the used in the rest of the method to test the
record existence.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation rules order ?

2008-07-07 Thread Dia
ok, thanks for the explanaition and the hint :)

On 7 juil, 08:47, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hey!
>
> The rules are indeed executed in order, but only the last validation
> rule that didn't pass will be shown. If you want Cake to stop
> validating if a condition isn't met, you can set 'last' => true
>
> Here the second rule will only be executed if the first rule passes:
>
> var $validate = array(
>                  'word' => array(
>                          array(
>                                  'required'      => true,
>                                  'allowEmpty'=> false,
>                                  'rule'          => '/\S+/',
>                                  'message'       => 'Required field.',
>                                  'last' => true
>                          ),
>                          array(
>                                  'rule'          => array('minLength',
> 3),
>                                  'message'       => '3 caracters min.'
>                          ),
>                  )
>          );
>
> On 6 heinä, 19:44, Dia <[EMAIL PROTECTED]> wrote:
>
> > Hi
>
> > I noticed a strange behaviour and wanted to know if it's there's a
> > order on executing validation rules
>
> > the example :
>
> > case 1 :
> >         var $validate = array(
> >                 'word' => array(
> >                         array(
> >                                 'required'      => true,
> >                                 'allowEmpty'=> false,
> >                                 'rule'          => '/\S+/',
> >                                 'message'       => 'Required field.'
> >                         ),
> >                         array(
> >                                 'rule'          => array('minLength', 3),
> >                                 'message'       => '3 caracters min.'
> >                         ),
> >                 )
> >         );
>
> > case 2 :
> >         var $validate = array(
> >                 'word' => array(
> >                         array(
> >                                 'rule'          => array('minLength', 3),
> >                                 'message'       => '3 caracters min.'
> >                         ),
> >                         array(
> >                                 'required'      => true,
> >                                 'allowEmpty'=> false,
> >                                 'rule'          => '/\S+/',
> >                                 'message'       => 'Required field.'
> >                         ),
> >                 )
> >         );
>
> > submitting an empty field will display '3 caracters min.' in case 1
> > and will display 'Required field.' in case 2...
> > for me it's a strange behaviour, I would think that rules are executed
> > in the order they are declared...
>
> > so how is determined the execution order ?
>
> > thanks in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation rules order ?

2008-07-06 Thread [EMAIL PROTECTED]

Hey!

The rules are indeed executed in order, but only the last validation
rule that didn't pass will be shown. If you want Cake to stop
validating if a condition isn't met, you can set 'last' => true

Here the second rule will only be executed if the first rule passes:

var $validate = array(
 'word' => array(
 array(
 'required'  => true,
 'allowEmpty'=> false,
 'rule'  => '/\S+/',
 'message'   => 'Required field.',
 'last' => true
 ),
 array(
 'rule'  => array('minLength',
3),
 'message'   => '3 caracters min.'
 ),
 )
 );



On 6 heinä, 19:44, Dia <[EMAIL PROTECTED]> wrote:
> Hi
>
> I noticed a strange behaviour and wanted to know if it's there's a
> order on executing validation rules
>
> the example :
>
> case 1 :
> var $validate = array(
> 'word' => array(
> array(
> 'required'  => true,
> 'allowEmpty'=> false,
> 'rule'  => '/\S+/',
> 'message'   => 'Required field.'
> ),
> array(
> 'rule'  => array('minLength', 3),
> 'message'   => '3 caracters min.'
> ),
> )
> );
>
> case 2 :
> var $validate = array(
> 'word' => array(
> array(
> 'rule'  => array('minLength', 3),
> 'message'   => '3 caracters min.'
> ),
> array(
> 'required'  => true,
> 'allowEmpty'=> false,
> 'rule'  => '/\S+/',
> 'message'   => 'Required field.'
> ),
> )
> );
>
> submitting an empty field will display '3 caracters min.' in case 1
> and will display 'Required field.' in case 2...
> for me it's a strange behaviour, I would think that rules are executed
> in the order they are declared...
>
> so how is determined the execution order ?
>
> thanks in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation rules order ?

2008-07-06 Thread Dia

PS: using 1.2 RC2
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model validation

2008-07-05 Thread Sai Krishna

I tried it all. It seems to be not a  problem of plurals, my colleague
is not a cake expert, he was just there for code review.

Is there any other setting to be done?

On Jul 4, 7:24 pm, "Jonathan Snook" <[EMAIL PROTECTED]> wrote:
> Go back to how you originally had it and then use franky's advice and
> just pluralize the table name.
>
> On Fri, Jul 4, 2008 at 10:10 AM, Sai Krishna <[EMAIL PROTECTED]> wrote:
>
> > It changed the file names accordingly
> > i.e
> > application_tool_controller is controller and class name is
> > ApplicationToolController
> > application_tool is the model name and class name is ApplicationTool
> > application_tools is the table name
>
> > with this view is getting messed up which has a javascript variable
> > defined in them.
>
> > My Old file naming was the other way
> > application_tools_controller is controller name while class name is
> > ApplicationToolsController
> > ApplicationTool is model name and while class name ApplicationTool
> > application_tools is the table name
>
> > with this view works fine, even saving of data and all other
> > functionality is achieved but data validation does not seem to
> > happen..  Are my old file namings  wrong?
>
> > On Jul 4, 6:20 pm, francky06l <[EMAIL PROTECTED]> wrote:
> >> What is your model file name ? Should be application_tool.php, table
> >> name should be plural : application_tools ..
> >> hth
>
> >> On Jul 4, 2:52 pm, Sai Krishna <[EMAIL PROTECTED]> wrote:
>
> >> > Hey Just an update on this. One of my fellow coder has said that I'm
> >> > doing a mistake by using plurals
> >> > My App controller name is plural to Model
>
> >> > If the controller name is
>
> >> > ApplicationToolsController and Model name is ApplicationTool and
> >> > database table is application_tool and view  directory name
> >> > application_tools.. I tried making everything singular with exception
> >> > of database table. but no luck.. Can somebody tell me where am I doing
> >> > wrong?
>
> >> > On Jul 4, 11:23 am, Sai Krishna <[EMAIL PROTECTED]> wrote:
>
> >> > > Hi,
>
> >> > > I'm a newbie  to cakePHP 1.2. I had been working module in which I had
> >> > > been doing the following model validation. The validation never fails,
> >> > > what am I doing wrong
>
> >> > > Model contains this
> >> > > -
> >> > >  var $name='MyModule';
> >> > >  var $validate = array(
> >> > >                         'module'=>array(
> >> > >                                 'rule'=>'numeric',
> >> > >                                 'message'=>'Not a valid module
> >> > > selected'
> >> > >                         ),
> >> > >                         'description'=>array(
> >> > >                                 'rule'=>array('custom','/[A-Z0-9_-\\\/
> >> > > [EMAIL PROTECTED]&\*\(\)]+/si')
> >> > >                                 'message'=>'Not a valid character in
> >> > > the description'
> >> > >                         )
>
> >> > >         );
> >> > > 
> >> > > And in Controller I do this, $this->data comes from a an ajax form
> >> > > 
> >> > > $this->Model->set($this->data);
> >> > > echo $this->Model->validates();
> >> > > 
> >> > > this validation ever returns 1. what am I doing wrong?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model validation

2008-07-04 Thread Jonathan Snook

Go back to how you originally had it and then use franky's advice and
just pluralize the table name.

On Fri, Jul 4, 2008 at 10:10 AM, Sai Krishna <[EMAIL PROTECTED]> wrote:
>
> It changed the file names accordingly
> i.e
> application_tool_controller is controller and class name is
> ApplicationToolController
> application_tool is the model name and class name is ApplicationTool
> application_tools is the table name
>
> with this view is getting messed up which has a javascript variable
> defined in them.
>
> My Old file naming was the other way
> application_tools_controller is controller name while class name is
> ApplicationToolsController
> ApplicationTool is model name and while class name ApplicationTool
> application_tools is the table name
>
> with this view works fine, even saving of data and all other
> functionality is achieved but data validation does not seem to
> happen..  Are my old file namings  wrong?
>
>
>
>
> On Jul 4, 6:20 pm, francky06l <[EMAIL PROTECTED]> wrote:
>> What is your model file name ? Should be application_tool.php, table
>> name should be plural : application_tools ..
>> hth
>>
>> On Jul 4, 2:52 pm, Sai Krishna <[EMAIL PROTECTED]> wrote:
>>
>> > Hey Just an update on this. One of my fellow coder has said that I'm
>> > doing a mistake by using plurals
>> > My App controller name is plural to Model
>>
>> > If the controller name is
>>
>> > ApplicationToolsController and Model name is ApplicationTool and
>> > database table is application_tool and view  directory name
>> > application_tools.. I tried making everything singular with exception
>> > of database table. but no luck.. Can somebody tell me where am I doing
>> > wrong?
>>
>> > On Jul 4, 11:23 am, Sai Krishna <[EMAIL PROTECTED]> wrote:
>>
>> > > Hi,
>>
>> > > I'm a newbie  to cakePHP 1.2. I had been working module in which I had
>> > > been doing the following model validation. The validation never fails,
>> > > what am I doing wrong
>>
>> > > Model contains this
>> > > -
>> > >  var $name='MyModule';
>> > >  var $validate = array(
>> > > 'module'=>array(
>> > > 'rule'=>'numeric',
>> > > 'message'=>'Not a valid module
>> > > selected'
>> > > ),
>> > > 'description'=>array(
>> > > 'rule'=>array('custom','/[A-Z0-9_-\\\/
>> > > [EMAIL PROTECTED]&\*\(\)]+/si')
>> > > 'message'=>'Not a valid character in
>> > > the description'
>> > > )
>>
>> > > );
>> > > 
>> > > And in Controller I do this, $this->data comes from a an ajax form
>> > > 
>> > > $this->Model->set($this->data);
>> > > echo $this->Model->validates();
>> > > 
>> > > this validation ever returns 1. what am I doing wrong?
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model validation

2008-07-04 Thread Sai Krishna

It changed the file names accordingly
i.e
application_tool_controller is controller and class name is
ApplicationToolController
application_tool is the model name and class name is ApplicationTool
application_tools is the table name

with this view is getting messed up which has a javascript variable
defined in them.

My Old file naming was the other way
application_tools_controller is controller name while class name is
ApplicationToolsController
ApplicationTool is model name and while class name ApplicationTool
application_tools is the table name

with this view works fine, even saving of data and all other
functionality is achieved but data validation does not seem to
happen..  Are my old file namings  wrong?




On Jul 4, 6:20 pm, francky06l <[EMAIL PROTECTED]> wrote:
> What is your model file name ? Should be application_tool.php, table
> name should be plural : application_tools ..
> hth
>
> On Jul 4, 2:52 pm, Sai Krishna <[EMAIL PROTECTED]> wrote:
>
> > Hey Just an update on this. One of my fellow coder has said that I'm
> > doing a mistake by using plurals
> > My App controller name is plural to Model
>
> > If the controller name is
>
> > ApplicationToolsController and Model name is ApplicationTool and
> > database table is application_tool and view  directory name
> > application_tools.. I tried making everything singular with exception
> > of database table. but no luck.. Can somebody tell me where am I doing
> > wrong?
>
> > On Jul 4, 11:23 am, Sai Krishna <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I'm a newbie  to cakePHP 1.2. I had been working module in which I had
> > > been doing the following model validation. The validation never fails,
> > > what am I doing wrong
>
> > > Model contains this
> > > -
> > >  var $name='MyModule';
> > >  var $validate = array(
> > >                         'module'=>array(
> > >                                 'rule'=>'numeric',
> > >                                 'message'=>'Not a valid module
> > > selected'
> > >                         ),
> > >                         'description'=>array(
> > >                                 'rule'=>array('custom','/[A-Z0-9_-\\\/
> > > [EMAIL PROTECTED]&\*\(\)]+/si')
> > >                                 'message'=>'Not a valid character in
> > > the description'
> > >                         )
>
> > >         );
> > > 
> > > And in Controller I do this, $this->data comes from a an ajax form
> > > 
> > > $this->Model->set($this->data);
> > > echo $this->Model->validates();
> > > 
> > > this validation ever returns 1. what am I doing wrong?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model validation

2008-07-04 Thread francky06l

What is your model file name ? Should be application_tool.php, table
name should be plural : application_tools ..
hth

On Jul 4, 2:52 pm, Sai Krishna <[EMAIL PROTECTED]> wrote:
> Hey Just an update on this. One of my fellow coder has said that I'm
> doing a mistake by using plurals
> My App controller name is plural to Model
>
> If the controller name is
>
> ApplicationToolsController and Model name is ApplicationTool and
> database table is application_tool and view  directory name
> application_tools.. I tried making everything singular with exception
> of database table. but no luck.. Can somebody tell me where am I doing
> wrong?
>
> On Jul 4, 11:23 am, Sai Krishna <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I'm a newbie  to cakePHP 1.2. I had been working module in which I had
> > been doing the following model validation. The validation never fails,
> > what am I doing wrong
>
> > Model contains this
> > -
> >  var $name='MyModule';
> >  var $validate = array(
> > 'module'=>array(
> > 'rule'=>'numeric',
> > 'message'=>'Not a valid module
> > selected'
> > ),
> > 'description'=>array(
> > 'rule'=>array('custom','/[A-Z0-9_-\\\/
> > [EMAIL PROTECTED]&\*\(\)]+/si')
> > 'message'=>'Not a valid character in
> > the description'
> > )
>
> > );
> > 
> > And in Controller I do this, $this->data comes from a an ajax form
> > 
> > $this->Model->set($this->data);
> > echo $this->Model->validates();
> > 
> > this validation ever returns 1. what am I doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model validation

2008-07-04 Thread Sai Krishna

Hey Just an update on this. One of my fellow coder has said that I'm
doing a mistake by using plurals
My App controller name is plural to Model

If the controller name is

ApplicationToolsController and Model name is ApplicationTool and
database table is application_tool and view  directory name
application_tools.. I tried making everything singular with exception
of database table. but no luck.. Can somebody tell me where am I doing
wrong?




On Jul 4, 11:23 am, Sai Krishna <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm a newbie  to cakePHP 1.2. I had been working module in which I had
> been doing the following model validation. The validation never fails,
> what am I doing wrong
>
> Model contains this
> -
>  var $name='MyModule';
>  var $validate = array(
>                         'module'=>array(
>                                 'rule'=>'numeric',
>                                 'message'=>'Not a valid module
> selected'
>                         ),
>                         'description'=>array(
>                                 'rule'=>array('custom','/[A-Z0-9_-\\\/
> [EMAIL PROTECTED]&\*\(\)]+/si')
>                                 'message'=>'Not a valid character in
> the description'
>                         )
>
>         );
> 
> And in Controller I do this, $this->data comes from a an ajax form
> 
> $this->Model->set($this->data);
> echo $this->Model->validates();
> 
> this validation ever returns 1. what am I doing wrong?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model Validation help

2008-06-06 Thread Turnquist, Jonah

Looking back over my last reply I think I might have sounded a bit
rude, sorry about that

I did the search as you said and found one instance of the function,
but was not able to make sense of it.  I did do some googling and
found this page though: http://grahambird.co.uk/cake/

quote from page:
What will Cake do for me?

Some of the things Cake does so you don’t have to:
* [...]
* automatically escapes data saved to the database (to prevent SQL
injection attacks)

That's all I needed to know.  Thanks for the help anyways

On Jun 6, 8:50 pm, "b logica" <[EMAIL PROTECTED]> wrote:
> Huh? Is it too difficult to open the file and search for the word 'escape'?
>
> I agree that Cake's inner workings are bloody mysterious, but if
> you're using PHP--period--"you should very well know" how to search a
> file for a method.
>
> On Fri, Jun 6, 2008 at 10:31 PM, Turnquist, Jonah <[EMAIL PROTECTED]> wrote:
>
> > If you are using cakephp and publish websites to the internet, you
> > should very well know if it is secure.  My question is do I have to do
> > something to the data before saving it to the database manually to
> > keep it mysql injection safe or does cake take care of that?
>
> > For instance do I need to use mysql_real_escape_string() with cake?
>
> > I  will look at the code too but as I can barely code with cake at
> > this point I doubt I will be able to understand it's inner workings
> > very well at this point either.
>
> > Thanks guys,
> > Jonah
>
> > On Jun 6, 5:18 pm, "b logica" <[EMAIL PROTECTED]> wrote:
> >> All of the various database frontends are in 
> >> cake/libs/model/datasources/dbo/
>
> >> On Fri, Jun 6, 2008 at 4:18 PM, Turnquist, Jonah <[EMAIL PROTECTED]> wrote:
>
> >> > Thank you! That was exactally what I was looking for.  That should
> >> > work nicely.
>
> >> > Still looking for the answer to this question though:
>
> >> > Also, does cakephp take care of mysql injection checking automagically
> >> > or do I have to call mysql_real_escape_string for everything
> >> > manually?   Or is there something else?
>
> >> > Thanks,
> >> > Jonah
>
> >> > On Jun 6, 7:02 am, Daniel Hofstetter <[EMAIL PROTECTED]> wrote:
> >> >> Hi Jonah,
>
> >> >> > Problem:
> >> >> > What if data is sent through that should NOT be stored in table?  How
> >> >> > do I stop that?  For example, say I had a column named
> >> >> > "do_not_store_data_here" in the table.  For some reason I do not want
> >> >> > any data stored there.  I can't think of any particular cases where I
> >> >> > would want to do that at the moment but just go with me.
>
> >> >> > I am asking how can I stop people from injecting data into there?  I
> >> >> > mean, they could easily inject it by sending post data with the key
> >> >> > data[Script][do_not_store_data_here].
>
> >> >> Have a look at the third parameter of Model::save(), it allows you to
> >> >> specify the fields which can be written.
>
> >> >> Hope that helps!
>
> >> >> --
> >> >> Daniel Hofstetterhttp://cakebaker.42dh.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model Validation help

2008-06-06 Thread b logica

Huh? Is it too difficult to open the file and search for the word 'escape'?

I agree that Cake's inner workings are bloody mysterious, but if
you're using PHP--period--"you should very well know" how to search a
file for a method.

On Fri, Jun 6, 2008 at 10:31 PM, Turnquist, Jonah <[EMAIL PROTECTED]> wrote:
>
> If you are using cakephp and publish websites to the internet, you
> should very well know if it is secure.  My question is do I have to do
> something to the data before saving it to the database manually to
> keep it mysql injection safe or does cake take care of that?
>
> For instance do I need to use mysql_real_escape_string() with cake?
>
> I  will look at the code too but as I can barely code with cake at
> this point I doubt I will be able to understand it's inner workings
> very well at this point either.
>
> Thanks guys,
> Jonah
>
> On Jun 6, 5:18 pm, "b logica" <[EMAIL PROTECTED]> wrote:
>> All of the various database frontends are in cake/libs/model/datasources/dbo/
>>
>> On Fri, Jun 6, 2008 at 4:18 PM, Turnquist, Jonah <[EMAIL PROTECTED]> wrote:
>>
>> > Thank you! That was exactally what I was looking for.  That should
>> > work nicely.
>>
>> > Still looking for the answer to this question though:
>>
>> > Also, does cakephp take care of mysql injection checking automagically
>> > or do I have to call mysql_real_escape_string for everything
>> > manually?   Or is there something else?
>>
>> > Thanks,
>> > Jonah
>>
>> > On Jun 6, 7:02 am, Daniel Hofstetter <[EMAIL PROTECTED]> wrote:
>> >> Hi Jonah,
>>
>> >> > Problem:
>> >> > What if data is sent through that should NOT be stored in table?  How
>> >> > do I stop that?  For example, say I had a column named
>> >> > "do_not_store_data_here" in the table.  For some reason I do not want
>> >> > any data stored there.  I can't think of any particular cases where I
>> >> > would want to do that at the moment but just go with me.
>>
>> >> > I am asking how can I stop people from injecting data into there?  I
>> >> > mean, they could easily inject it by sending post data with the key
>> >> > data[Script][do_not_store_data_here].
>>
>> >> Have a look at the third parameter of Model::save(), it allows you to
>> >> specify the fields which can be written.
>>
>> >> Hope that helps!
>>
>> >> --
>> >> Daniel Hofstetterhttp://cakebaker.42dh.com
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model Validation help

2008-06-06 Thread Turnquist, Jonah

If you are using cakephp and publish websites to the internet, you
should very well know if it is secure.  My question is do I have to do
something to the data before saving it to the database manually to
keep it mysql injection safe or does cake take care of that?

For instance do I need to use mysql_real_escape_string() with cake?

I  will look at the code too but as I can barely code with cake at
this point I doubt I will be able to understand it's inner workings
very well at this point either.

Thanks guys,
Jonah

On Jun 6, 5:18 pm, "b logica" <[EMAIL PROTECTED]> wrote:
> All of the various database frontends are in cake/libs/model/datasources/dbo/
>
> On Fri, Jun 6, 2008 at 4:18 PM, Turnquist, Jonah <[EMAIL PROTECTED]> wrote:
>
> > Thank you! That was exactally what I was looking for.  That should
> > work nicely.
>
> > Still looking for the answer to this question though:
>
> > Also, does cakephp take care of mysql injection checking automagically
> > or do I have to call mysql_real_escape_string for everything
> > manually?   Or is there something else?
>
> > Thanks,
> > Jonah
>
> > On Jun 6, 7:02 am, Daniel Hofstetter <[EMAIL PROTECTED]> wrote:
> >> Hi Jonah,
>
> >> > Problem:
> >> > What if data is sent through that should NOT be stored in table?  How
> >> > do I stop that?  For example, say I had a column named
> >> > "do_not_store_data_here" in the table.  For some reason I do not want
> >> > any data stored there.  I can't think of any particular cases where I
> >> > would want to do that at the moment but just go with me.
>
> >> > I am asking how can I stop people from injecting data into there?  I
> >> > mean, they could easily inject it by sending post data with the key
> >> > data[Script][do_not_store_data_here].
>
> >> Have a look at the third parameter of Model::save(), it allows you to
> >> specify the fields which can be written.
>
> >> Hope that helps!
>
> >> --
> >> Daniel Hofstetterhttp://cakebaker.42dh.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model Validation help

2008-06-06 Thread b logica

All of the various database frontends are in cake/libs/model/datasources/dbo/

On Fri, Jun 6, 2008 at 4:18 PM, Turnquist, Jonah <[EMAIL PROTECTED]> wrote:
>
> Thank you! That was exactally what I was looking for.  That should
> work nicely.
>
> Still looking for the answer to this question though:
>
> Also, does cakephp take care of mysql injection checking automagically
> or do I have to call mysql_real_escape_string for everything
> manually?   Or is there something else?
>
> Thanks,
> Jonah
>
> On Jun 6, 7:02 am, Daniel Hofstetter <[EMAIL PROTECTED]> wrote:
>> Hi Jonah,
>>
>> > Problem:
>> > What if data is sent through that should NOT be stored in table?  How
>> > do I stop that?  For example, say I had a column named
>> > "do_not_store_data_here" in the table.  For some reason I do not want
>> > any data stored there.  I can't think of any particular cases where I
>> > would want to do that at the moment but just go with me.
>>
>> > I am asking how can I stop people from injecting data into there?  I
>> > mean, they could easily inject it by sending post data with the key
>> > data[Script][do_not_store_data_here].
>>
>> Have a look at the third parameter of Model::save(), it allows you to
>> specify the fields which can be written.
>>
>> Hope that helps!
>>
>> --
>> Daniel Hofstetterhttp://cakebaker.42dh.com
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model Validation help

2008-06-06 Thread Turnquist, Jonah

Thank you! That was exactally what I was looking for.  That should
work nicely.

Still looking for the answer to this question though:

Also, does cakephp take care of mysql injection checking automagically
or do I have to call mysql_real_escape_string for everything
manually?   Or is there something else?

Thanks,
Jonah

On Jun 6, 7:02 am, Daniel Hofstetter <[EMAIL PROTECTED]> wrote:
> Hi Jonah,
>
> > Problem:
> > What if data is sent through that should NOT be stored in table?  How
> > do I stop that?  For example, say I had a column named
> > "do_not_store_data_here" in the table.  For some reason I do not want
> > any data stored there.  I can't think of any particular cases where I
> > would want to do that at the moment but just go with me.
>
> > I am asking how can I stop people from injecting data into there?  I
> > mean, they could easily inject it by sending post data with the key
> > data[Script][do_not_store_data_here].
>
> Have a look at the third parameter of Model::save(), it allows you to
> specify the fields which can be written.
>
> Hope that helps!
>
> --
> Daniel Hofstetterhttp://cakebaker.42dh.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Model Validation help

2008-06-06 Thread Daniel Hofstetter

Hi Jonah,

> Problem:
> What if data is sent through that should NOT be stored in table?  How
> do I stop that?  For example, say I had a column named
> "do_not_store_data_here" in the table.  For some reason I do not want
> any data stored there.  I can't think of any particular cases where I
> would want to do that at the moment but just go with me.
>
> I am asking how can I stop people from injecting data into there?  I
> mean, they could easily inject it by sending post data with the key
> data[Script][do_not_store_data_here].

Have a look at the third parameter of Model::save(), it allows you to
specify the fields which can be written.

Hope that helps!

--
Daniel Hofstetter
http://cakebaker.42dh.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation - how do you handle different rules for different forms?

2008-04-15 Thread R. Rajesh Jeba Anbiah

On Apr 14, 4:40 am, keymaster <[EMAIL PROTECTED]> wrote:
> Other than the conditional validation solution in the bakery, (which
> seems to work, but is not necessarily a first choice, it's more of a
> workaround) is there a more "core" approach to dealing with fields
> which have different validation requirements for different forms?
   

The model based validation is a huge pain. FWIW, grigri gave me
this for user level based validations 
http://groups.google.com/group/cake-php/msg/88652124169dd408

--
  
Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation - how do you handle different rules for different forms?

2008-04-14 Thread Dardo Sordi Bogado

How about this?

AppModel:

function setValidation($validation) {
 $this->__restoreValidation = $this->validate;
 if (isArray($validation)) {
$this->validate = $validation;
 } else {
$validation = 'validate_' . $validation;
$this->validate = $this->$validation;
 }
}

function restoreValidation() {
$this->validate =   $this->__restoreValidation
}

In your model:

function register($data) {
  $this->setValidation('register');
  $result =  $this->save($data);
  $this->restoreValidation();
  return $result;
}


I was thinking in putting all of this in a behavior...

On Mon, Apr 14, 2008 at 6:55 AM, Flipflops <[EMAIL PROTECTED]> wrote:
>
>  Hi
>
>  That's a really good idea  - you also wouldn't have to worry about
>  using the wrong validation array by mistake - which I have done - and
>  it took me an age before I figured out what the problem was.
>
>  Cheers
>
>
>
>  On Apr 14, 10:16 am, keymaster <[EMAIL PROTECTED]> wrote:
>  > oops, that should read:
>  >
>  > function beforeValidate(){
>  >
>  >  // assume $action is set to current action.
>  >  if (isset($this->validateArray[$action])) {
>  >
>  >   // reassign the $validate variable.
>  >   $this->validate = $this->validateArray[$action];
>  >  }
>  >
>  > }
>  >
>  > The beforeValidate() can be put into the appModel to apply to all your
>  > models.
>  >
>  > This way your controllers never have to worry about any of this
>  > validation stuff, as it should be.
>  >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation - how do you handle different rules for different forms?

2008-04-14 Thread Flipflops

Hi

That's a really good idea  - you also wouldn't have to worry about
using the wrong validation array by mistake - which I have done - and
it took me an age before I figured out what the problem was.

Cheers

On Apr 14, 10:16 am, keymaster <[EMAIL PROTECTED]> wrote:
> oops, that should read:
>
> function beforeValidate(){
>
>  // assume $action is set to current action.
>  if (isset($this->validateArray[$action])) {
>
>   // reassign the $validate variable.
>   $this->validate = $this->validateArray[$action];
>  }
>
> }
>
> The beforeValidate() can be put into the appModel to apply to all your
> models.
>
> This way your controllers never have to worry about any of this
> validation stuff, as it should be.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation - how do you handle different rules for different forms?

2008-04-14 Thread keymaster

oops, that should read:

function beforeValidate(){

 // assume $action is set to current action.
 if (isset($this->validateArray[$action])) {

  // reassign the $validate variable.
  $this->validate = $this->validateArray[$action];
 }

}

The beforeValidate() can be put into the appModel to apply to all your
models.

This way your controllers never have to worry about any of this
validation stuff, as it should be.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation - how do you handle different rules for different forms?

2008-04-14 Thread keymaster

Beautiful.

The only disadvantage I see is somewhat semantic. The controller
shouldn't be telling the model which validation array to use.

I wonder if this could be improved by having the model transparently
perform the $validate re-assignment in beforeValidate(), using the
current action as the key.

Something like this:


... in your model constructor:

$validateArray['login'] = $validate_login;
$validateArray['register'] = $validate_register;

... in your model's beforeValidate callback:

function beforeValidate(){

 // assume $action is set to current action.
 if (isset($this->validateArray[$action])) {

  // reassign the $validate variable.
  $validate = $this->validateArray[$action];
 }
}


etc  .
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation - how do you handle different rules for different forms?

2008-04-14 Thread Flipflops

This is the way I do it (haven't tried it in 1.2 - but I see no reason
why it wouldn't work).

I've been using this in loads of 1.1.x based sites together Evan
Sagge's excellent validation code 
http://bakery.cakephp.org/articles/view/more-improved-advanced-validation

In your model define a number of different validation arrays as
required:

var $validate = array();

var $validate_register = array(
'title' => array('required'),
'first_name' => array('required'),
'last_name' => array('required'),
'username' => array('required', 'unique'),
'email' => array('required', 'unique', 'email'),
'passwd' => array('required'),
'passwd' => array('length' => array('min' => 8, 'max' => 20)),
'postcode' => array('required','postcode'),
'agree_terms' => array('required'),



);

var $validate_details = array(
'title' => array('required'),
'first_name' => array('required'),
'last_name' => array('required'),
'username' => array('required', 'unique'),
'email' => array('required', 'unique', 'email'),
'postcode' => array('required','postcode'),



);


var $validate_edit_password = array(
'passwd' => array('required'),
'passwd' => array('length' => array('min' => 8, 'max' => 20)),
);

Then in your controller you just select the validation you want to use
depending on context and over-ride the default validation array e.g.

function register()
{
$this->User->recursive = 0;

$this->User->validate = $this->User->validate_register;

// etc.
}

function members_details()
   {
$this->User->recursive = 0;

$this->User->validate = $this->User->validate_details;

$this->layout = "member";
// etc.
}




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation - how do you handle different rules for different forms?

2008-04-14 Thread keymaster

Thanks, but the update vs.create distinction is not the problem here.

We always want a country mandatory, whether the user is registering
(ie. creating a new record), or changing his profile (ie. updating).

But we don't need a country when the user logs in, or when the user
requests a password change.

All these forms: registration, updateProfile, login, changePassword,
forgotPassword are validated against the user model. But the
validation rules have to be different for each form.

Perhaps a stronger example is the password: it is mandatory on the
registration form, the login form, and the changePassword form; but,
is not required on the forgotPassword form, or the updateProfile form.

It makes sense to have the data "type" and "values" be defined at the
model level, since these are characteristics of the data. However,
whether the field is mandatory or not, that is often more a
characteristic of the form than the data.

Any ideas?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation - how do you handle different rules for different forms?

2008-04-13 Thread Joel

The cookbook has what you need:  http://book.cakephp.org/view/131/on

-Joel.

On Apr 13, 7:40 pm, keymaster <[EMAIL PROTECTED]> wrote:
> Other than the conditional validation solution in the bakery, (which
> seems to work, but is not necessarily a first choice, it's more of a
> workaround) is there a more "core" approach to dealing with fields
> which have different validation requirements for different forms?
>
> The classic example is the login form vs. the registration form, both
> of whose fields are validated against the user model.
>
> Both forms have username and password, but on the registration form
> other fields are also mandatory.
>
> So, if we make, for example, the country field mandatory for the
> registration form, it will also be mandatory for the login form, which
> we don't want.
>
> Each field in the model can have only one set of validation rules.
> Perhaps what we really need is the capability for mutliple sets of
> rules per field, with each set targetted to a form or action (as I saw
> in an earlier post on this forum).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation and error messages in Cake 1.2

2007-07-18 Thread pihentagy

On Jun 12, 3:18 pm, "jitka (poLK)" <[EMAIL PROTECTED]> wrote:
> --- want to turn your app to multilanguage one. So you will modify
> your model's code, or implement some model's behavior, or customize
> some helper, or anything from above WITH i18n of custom
> messages... ...or anything else just because of wrong decision, which
> seemed like smart way ;)

Hi!

Ok, then where should I specify error messages, when the validation
fails, if my app is multilingual?

And of course I don't want to write the same error message in every
form?

thanks
Gergo


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation and error messages in Cake 1.2

2007-06-12 Thread jitka (poLK)

My personal opinion is that not everything what is possible is also
automatically right. I understand benefits of error messages in model,
but those benefits are gone just in moment you will (for example):

--- let anyone else touch your code - you can be sure they will modify
messages in your models instead of adding 'error' => 'Custom message'
to your inputs/errTags (or turning 'error' => true to 'error' =>
'Custom message'. And I don't know how you, but I don't want anyone
touch my validation rules in model ;)
--- want to turn your app to multilanguage one. So you will modify
your model's code, or implement some model's behavior, or customize
some helper, or anything from above WITH i18n of custom
messages... ...or anything else just because of wrong decision, which
seemed like smart way ;)

I hope you see at least one point now. From my point of view: you may
say anything you want, but validation of data and error messages for
humans are related, but they doesn't belong to same place. It is user
who cares about stupid-proof text messages what goes wrong. With your
philosophy - I am sure that you will surely end with tootip messages
in model also, after your app will grow or be used by non-techs...

IMHO fact that mariano is not doing it in examples of multiple
validation rules in his article at bakery is for a reason.

Just my 2 cents.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation and error messages in Cake 1.2

2007-06-12 Thread R. Rajesh Jeba Anbiah

On Jun 12, 3:52 pm, "Dr. Tarique Sani" <[EMAIL PROTECTED]> wrote:
> On 6/12/07, R.RajeshJebaAnbiah<[EMAIL PROTECTED]> wrote:
> >I suppose the correct approach is to have error messages in model
> > and then override it in form::input() whenever necessary.
>
> Hmmm the classic "negative number in red" case
>
> The argument against messages in model is that the messages are parts
> of display logic What you say is convenient for all purposes...

Benefits:
1. You don't have to switch to model and view to define the rule and
messages. (More readability and manageability)
2. You don't have to rewrite the same messages whenever you reuse the
model (reusability)

Incidentally, however, I find that having model-based validation is a
kind of problem for sometime. I'll add a new thread sometime later to
see if I can get any good suggestions.

--
  
Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation and error messages in Cake 1.2

2007-06-12 Thread Dr. Tarique Sani

On 6/12/07, R. Rajesh Jeba Anbiah <[EMAIL PROTECTED]> wrote:
>
>I suppose the correct approach is to have error messages in model
> and then override it in form::input() whenever necessary.
>

Hmmm the classic "negative number in red" case

The argument against messages in model is that the messages are parts
of display logic What you say is convenient for all purposes...

T


-- 
=
Cheesecake-Photoblog: http://cheesecake-photoblog.org
PHP for E-Biz: http://sanisoft.com
=

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation and error messages in Cake 1.2

2007-06-12 Thread R. Rajesh Jeba Anbiah

On Jun 11, 6:56 pm, "Dr. Tarique Sani" <[EMAIL PROTECTED]> wrote:
> On 6/11/07, Ketan Patel <[EMAIL PROTECTED]> wrote:
>
> > Check out simple example at
> >http://bin.cakephp.org/view/610862726
  
> Perhaps the technically correct way is *not to have the error messages
> in model* - there is an article in Bakery by Mariano on how to do it
> with 1.2

   I suppose the correct approach is to have error messages in model
and then override it in form::input() whenever necessary.

--
  
Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation and error messages in Cake 1.2

2007-06-11 Thread Jonathan Langevin
Link to that article:
http://bakery.cakephp.org/articles/view/multiple-rules-of-validation-per-field-in-cakephp-1-2

On 6/11/07, Dr. Tarique Sani <[EMAIL PROTECTED]> wrote:
>
>
> On 6/11/07, Ketan Patel <[EMAIL PROTECTED]> wrote:
> >
> > Check out simple example at
> > http://bin.cakephp.org/view/610862726
> >
> > You are mixing and matching two different things. Use this simple
> > example as starting point .
> >
>
> Perhaps the technically correct way is *not to have the error messages
> in model* - there is an article in Bakery by Mariano on how to do it
> with 1.2
>
> Tarique
>
> --
> =
> Cheesecake-Photoblog: http://cheesecake-photoblog.org
> PHP for E-Biz: http://sanisoft.com
> =
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation and error messages in Cake 1.2

2007-06-11 Thread Dr. Tarique Sani

On 6/11/07, Ketan Patel <[EMAIL PROTECTED]> wrote:
>
> Check out simple example at
> http://bin.cakephp.org/view/610862726
>
> You are mixing and matching two different things. Use this simple
> example as starting point .
>

Perhaps the technically correct way is *not to have the error messages
in model* - there is an article in Bakery by Mariano on how to do it
with 1.2

Tarique

-- 
=
Cheesecake-Photoblog: http://cheesecake-photoblog.org
PHP for E-Biz: http://sanisoft.com
=

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation and error messages in Cake 1.2

2007-06-11 Thread Ketan Patel

Check out simple example at
http://bin.cakephp.org/view/610862726

You are mixing and matching two different things. Use this simple
example as starting point .

Ketan :-)

ne0d1n wrote:
> In new $validate array there is 'message' key obviously for error
> messages.
> (see example in http://bin.cakephp.org/view/152660210)
>
> Should I use tagErrorMsg to display it?
> Could you give any working example to display error validation message
> specified in $validate?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: model validation seems to have a serious logic flaw

2006-11-02 Thread nate

It is written that way to allow saveField and other features to work
properly.  Cake 1.2 will feature functionality that allows you to check
if a field is set, but in the meantime you are more than welcome to use
a callback like beforeValidate, to make sure all fields are set.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: model validation seems to have a serious logic flaw

2006-11-02 Thread [EMAIL PROTECTED]

Although I completely agree with you and I have wondered about the
design logic behind this myself, I think changing this behavior will
have a big impact on existing applications.

Having said that, I wouldn't mind refactoring my code to support proper
Model validation.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---