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.


Model Validation

2014-07-30 Thread Sudhir Pandey
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.


Re: Multiple Model Validation

2013-12-16 Thread Reuben
>From the controller, you can access $this->validationErrors to view 
validation errors from multiple models.

Though from your example, if you were saving an Order, wouldn't you want to 
look at $this->Order->validationErrors to see all the errors associated 
with that save?

Regards
Reuben Helms

On Tuesday, 17 December 2013 02:59:59 UTC+10, advantage+ wrote:
>
> When doing something like this:
>
>  
>
> if($this->Order->saveAssociated($this->request->data, array('validate' => 
> 'first'))){
>
> good stuff….. 
>
> } else {
>
> 
>
> echo 'hello';
>
> debug($this->User->validationErrors);
>
> die;
>
> }
>
>  
>
> How do I get the list of validation errors?
>
> I could not seem to find the answer anywhere.
>
>  
>
> Thanks,
>
>  
>
> Dave
>

-- 
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/groups/opt_out.


Multiple Model Validation

2013-12-16 Thread Advantage+
When doing something like this:

 

if($this->Order->saveAssociated($this->request->data, array('validate' =>
'first'))){

good stuff... 

} else {



echo 'hello';

debug($this->User->validationErrors);

die;

}

 

How do I get the list of validation errors?

I could not seem to find the answer anywhere.

 

Thanks,

 

Dave

-- 
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/groups/opt_out.


Model validation rule in cake1.3

2013-04-20 Thread Chris
Hi guys,... 
is there a way to validate rule, NOT to submit if string consist "<", 
"script", "javascript" etc,... 
here is my code: 

  'name' => array(
  'rule' => '/^<\w+|<|script|java|javascript|>$/',
  'required' => false,
  'allowEmpty' => false,
  'message' => 'forbidden entry',
), 

thanks in advance 
chris 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: CKEditor and model validation

2013-04-15 Thread angel reyes
Thanks it works.

On Sunday, April 14, 2013 12:54:42 PM UTC-7, frederikjacques wrote:
>
> Hi Chris,
>
> I've written a blog post about this issue with sample code.
> You can read it here 
> http://blog.the-nerd.be/2013/04/add-ckeditor-to-cakephp-with-model-validation/
>
> Cheers,
> Frederik
>
> On Saturday, April 13, 2013 8:35:42 PM UTC+2, Chris wrote:
>>
>> hi frederik,... 
>> I have a problem submitting with ckeditor,... this is my form,... but its 
>> not passing content to controller,... 
>>
>> Html->script('ckeditor/ckeditor'); ?>
>>
>> 
>> Form->textarea('content', array('rows' => '3', 'cols' 
>> => '5', 'class' => 'ckeditor')); ?>
>> 
>>
>> can you share with us please,... 
>> thanks in advance 
>> chris
>>
>> On Saturday, April 13, 2013 9:11:15 AM UTC-7, frederikjacques wrote:
>>>
>>> Hi all,
>>>
>>> I was wondering how you can use CKEditor and the model validation array.
>>> I got my textareas changed to CKEditors, but now my validation fails. 
>>> If I remove a rule like non-empty everything works again, but I would 
>>> rather keep my validation rules :-)
>>>
>>> Cheers,
>>> Frederik
>>>
>>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: CKEditor and model validation

2013-04-15 Thread Chris
hi frederik,... thank you for your reply,... 
however 'required' => false did not help me,... I have a validation rule 
set in a controller function: 

  if(empty($this->data))
  {
echo '';
echo '';
 echo 'unexpected';
echo '';
echo '';
 $response = $this->requestAction('/photo_comments/ajax_show' .'/'. 
$photo['Photo']['id'], array('return'));
echo $response; 
die();
  }
  elseif(empty($this->data['PhotoComment']['content']))
  {
echo '';
echo '';
 echo 'please fill in your comments';
echo '';
echo '';
 $response = $this->requestAction('/photo_comments/ajax_show' .'/'. 
$photo['Photo']['id'], array('return'));
echo $response; 
die();
  }

submitting data not getting thru,... getting response from echo 'please 
fill in your comments'; what that means is my data can't get thru,... 

thanks 
chris 


On Sunday, April 14, 2013 12:54:42 PM UTC-7, frederikjacques wrote:
>
> Hi Chris,
>
> I've written a blog post about this issue with sample code.
> You can read it here 
> http://blog.the-nerd.be/2013/04/add-ckeditor-to-cakephp-with-model-validation/
>
> Cheers,
> Frederik
>
> On Saturday, April 13, 2013 8:35:42 PM UTC+2, Chris wrote:
>>
>> hi frederik,... 
>> I have a problem submitting with ckeditor,... this is my form,... but its 
>> not passing content to controller,... 
>>
>> Html->script('ckeditor/ckeditor'); ?>
>>
>> 
>> Form->textarea('content', array('rows' => '3', 'cols' 
>> => '5', 'class' => 'ckeditor')); ?>
>> 
>>
>> can you share with us please,... 
>> thanks in advance 
>> chris
>>
>> On Saturday, April 13, 2013 9:11:15 AM UTC-7, frederikjacques wrote:
>>>
>>> Hi all,
>>>
>>> I was wondering how you can use CKEditor and the model validation array.
>>> I got my textareas changed to CKEditors, but now my validation fails. 
>>> If I remove a rule like non-empty everything works again, but I would 
>>> rather keep my validation rules :-)
>>>
>>> Cheers,
>>> Frederik
>>>
>>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: CKEditor and model validation

2013-04-14 Thread frederikjacques
Hi Chris,

I've written a blog post about this issue with sample code.
You can read it 
here 
http://blog.the-nerd.be/2013/04/add-ckeditor-to-cakephp-with-model-validation/

Cheers,
Frederik

On Saturday, April 13, 2013 8:35:42 PM UTC+2, Chris wrote:
>
> hi frederik,... 
> I have a problem submitting with ckeditor,... this is my form,... but its 
> not passing content to controller,... 
>
> Html->script('ckeditor/ckeditor'); ?>
>
> 
> Form->textarea('content', array('rows' => '3', 'cols' 
> => '5', 'class' => 'ckeditor')); ?>
> 
>
> can you share with us please,... 
> thanks in advance 
> chris
>
> On Saturday, April 13, 2013 9:11:15 AM UTC-7, frederikjacques wrote:
>>
>> Hi all,
>>
>> I was wondering how you can use CKEditor and the model validation array.
>> I got my textareas changed to CKEditors, but now my validation fails. 
>> If I remove a rule like non-empty everything works again, but I would 
>> rather keep my validation rules :-)
>>
>> Cheers,
>> Frederik
>>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: CKEditor and model validation

2013-04-13 Thread Chris
hi frederik,... 
I have a problem submitting with ckeditor,... this is my form,... but its 
not passing content to controller,... 

Html->script('ckeditor/ckeditor'); ?>


Form->textarea('content', array('rows' => '3', 'cols' => 
'5', 'class' => 'ckeditor')); ?>


can you share with us please,... 
thanks in advance 
chris

On Saturday, April 13, 2013 9:11:15 AM UTC-7, frederikjacques wrote:
>
> Hi all,
>
> I was wondering how you can use CKEditor and the model validation array.
> I got my textareas changed to CKEditors, but now my validation fails. 
> If I remove a rule like non-empty everything works again, but I would 
> rather keep my validation rules :-)
>
> Cheers,
> Frederik
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




CKEditor and model validation

2013-04-13 Thread frederikjacques
Hi all,

I was wondering how you can use CKEditor and the model validation array.
I got my textareas changed to CKEditors, but now my validation fails. 
If I remove a rule like non-empty everything works again, but I would 
rather keep my validation rules :-)

Cheers,
Frederik

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




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.




Model Validation Error Message

2013-01-18 Thread Michael Gaiser
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: Associative model validation fails, but does not report.

2012-06-07 Thread Michael Gaiser
All the tables that involve the users modifying data are set to innoDB for
the increased data integrity. I originally wasnt giving the saveAll any
arguments, but tried to set 'Validate'=>'first' as I saw in one example and
that didnt work either.

I finally got the errors propagating back to my view from the associated
model validation (I have a feeling it was a cache thing) but the validation
is ultimately failing because for some reason, the validation rule is being
run twice. The first time, it works and returns true but it is then run
again but the link to $this->Domain->data has been cleared so my
tests ultimately fail since it cannot find the expected data. Why is the
validation run twice and how come the data is being cleared the 2nd time
through?

-- 
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: Associative model validation fails, but does not report.

2012-06-07 Thread bs28723
Just a thought - do you have the saveAssociated set to Atomic? and does 
the DB support this?
I have not done a lot of testing on this, but i had to change the table 
defaults to innoDB to support transactions, mySQL defaults to MyISAM.

On 6/7/2012 1:10 AM, Michael Gaiser [via CakePHP] wrote:
> So I have a form in my domains/add view. All the domain input fields
> save their data just fine when the form is submitted. The problem is
> that there is another field (Characters.0.character_id) that is to
> save its data to an hasMany associated join model (CharactersDomain).
> In the CharactersDomain model I have added a validation rule to the
> "character_id" which I have set to always fail for testing purposes.
> When I use saveAll to save the Domain data and the associated
> character_id in the CharactersDomain the Domain record is saved to the
> database but the CharactersDomain record is not (because the
> validation failed).
>
> So I have 2 questions:
>
> 1: I thought saveAll was only to save the data if all the validations
> passed. Why was the Domain record saved if the CharactersDomain record
> failed its validation?
> 2: When the CharactersDomain fails, I want it to display its error
> message on the Characters.0.character_id input. Why did it not show
> the error?
>
> -- 
> 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
> [hidden email]  For 
> more options, visit this group at http://groups.google.com/group/cake-php
>
>
> 
> If you reply to this email, your message will be added to the 
> discussion below:
> http://cakephp.1045679.n5.nabble.com/Associative-model-validation-fails-but-does-not-report-tp5708611.html
>  
>
> To start a new topic under CakePHP, email 
> ml-node+s1045679n125572...@n5.nabble.com
> To unsubscribe from CakePHP, click here 
> <http://cakephp.1045679.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1255722&code=YmlsbC5zdG9sdHpAYm9vc3RlcndlYnNvbHV0aW9ucy5jb218MTI1NTcyMnwtNTU0NTk2MTUy>.
> NAML 
> <http://cakephp.1045679.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>  
>


--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/Associative-model-validation-fails-but-does-not-report-tp5708611p5708630.html
Sent from the CakePHP mailing list archive at Nabble.com.

-- 
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


Associative model validation fails, but does not report.

2012-06-06 Thread Michael Gaiser
So I have a form in my domains/add view. All the domain input fields
save their data just fine when the form is submitted. The problem is
that there is another field (Characters.0.character_id) that is to
save its data to an hasMany associated join model (CharactersDomain).
In the CharactersDomain model I have added a validation rule to the
"character_id" which I have set to always fail for testing purposes.
When I use saveAll to save the Domain data and the associated
character_id in the CharactersDomain the Domain record is saved to the
database but the CharactersDomain record is not (because the
validation failed).

So I have 2 questions:

1: I thought saveAll was only to save the data if all the validations
passed. Why was the Domain record saved if the CharactersDomain record
failed its validation?
2: When the CharactersDomain fails, I want it to display its error
message on the Characters.0.character_id input. Why did it not show
the error?

-- 
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: custom model validation question

2012-06-06 Thread Michael Gaiser
ok. i figured it out. The models being saved can be accessed in the
validation rule through $this->data.

On Wed, Jun 6, 2012 at 10:29 AM, Michael Gaiser  wrote:
> I guess my question is: How do you get access to all the other
> associated data that is being saved? I can set it up so I catch it
> before the save happens, but it feels kind of hacky and does not make
> use of the field error message code.

-- 
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: custom model validation question

2012-06-06 Thread Michael Gaiser
I guess my question is: How do you get access to all the other
associated data that is being saved? I can set it up so I catch it
before the save happens, but it feels kind of hacky and does not make
use of the field error message code.

-- 
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: custom model validation question

2012-06-05 Thread Michael Gaiser
ok... How would you test if other associations were submitted? The
example in the docs does not really work for what I want to test
against. How do I get access to all the other fields submitted to be
saved?

On Tue, Jun 5, 2012 at 9:44 PM, John Hardy  wrote:
> Write your own validation routine.
>
>
> On Jun 5, 2012, at 5:45 PM, Michael Gaiser wrote:
>
>> I have a Domain Model that has 4 "has Many" relationships with 4
>> different join models (Character, Clan, Covenant, Coterie). When
>> creating a new record, the user is presented with 4 option boxes, each
>> filled with different data pertaining to the 4 associated models but
>> defaulting to an empty option. The Rule I want to create will require
>> one field to contain selected data, but the other 3 to be empty. If
>> the user selected two or more options, I want to have an error
>> displayed on the option boxes that the user selected. Any ideas?
>> Thanks.
>>
>> --
>> 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

-- 
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: custom model validation question

2012-06-05 Thread John Hardy
Write your own validation routine.


On Jun 5, 2012, at 5:45 PM, Michael Gaiser wrote:

> I have a Domain Model that has 4 "has Many" relationships with 4
> different join models (Character, Clan, Covenant, Coterie). When
> creating a new record, the user is presented with 4 option boxes, each
> filled with different data pertaining to the 4 associated models but
> defaulting to an empty option. The Rule I want to create will require
> one field to contain selected data, but the other 3 to be empty. If
> the user selected two or more options, I want to have an error
> displayed on the option boxes that the user selected. Any ideas?
> Thanks.
> 
> -- 
> 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


custom model validation question

2012-06-05 Thread Michael Gaiser
I have a Domain Model that has 4 "has Many" relationships with 4
different join models (Character, Clan, Covenant, Coterie). When
creating a new record, the user is presented with 4 option boxes, each
filled with different data pertaining to the 4 associated models but
defaulting to an empty option. The Rule I want to create will require
one field to contain selected data, but the other 3 to be empty. If
the user selected two or more options, I want to have an error
displayed on the option boxes that the user selected. Any ideas?
Thanks.

-- 
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 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


Model Validation field names

2012-04-14 Thread CyberGlitch
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.



 

 $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


Re: Translate model validation question

2011-10-14 Thread heohni
Hi,

thanks, this works for me except the problem that I get this error
message:
Do you know why this is happening?

Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near '_validationRules' at line 1 [COREcake/libs/
model/datasources/dbo_source.php, line 684]Code | Context
$out = null;
if ($error) {
trigger_error('' . __('SQL Error:', true) . " {$this->error}", E_USER_WARNING);$sql=   "_validationRules"
$error  =   "1064: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near '_validationRules' at line 1"
$out=   nullDboSource::showQuery() - COREcake/libs/model/datasources/
dbo_source.php, line 684
DboSource::execute() - COREcake/libs/model/datasources/dbo_source.php,
line 266
DboSource::fetchAll() - COREcake/libs/model/datasources/
dbo_source.php, line 410
DboSource::query() - COREcake/libs/model/datasources/dbo_source.php,
line 364
Model::call__() - COREcake/libs/model/model.php, line 502
Overloadable::__call() - COREcake/libs/overloadable_php5.php, line 50
Contact::_validationRules() - APP/app_model.php, line 39
AppModel::__construct() - APP/app_model.php, line 39
Contact::__construct() - APP/models/contact.php, line 15
ClassRegistry::init() - COREcake/libs/class_registry.php, line 141
Controller::loadModel() - COREcake/libs/controller/controller.php,
line 637
Controller::constructClasses() - COREcake/libs/controller/
controller.php, line 493
Dispatcher::_invoke() - COREcake/dispatcher.php, line 186
Dispatcher::dispatch() - COREcake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 88Query: _validationRules



On 14 Okt., 05:00, "Dr. Loboto"  wrote:
> http://book.cakephp.org/view/1230/Localization-in-CakePHP
>
> Reload invalidate() method.
>
> On 13 ÏËÔ, 18:38, heohni  wrote:
>
>
>
> > Hi,
>
> > I have this in my app_model.php
> > public $validate = array();
>
> > š š public function __construct($id = false, $table = null, $ds =
> > null) {
> > š š š š parent::__construct($id, $table, $ds);
>
> > š š š š $this->_validationRules();
> > š š }
>
> > And this way I have my model
> > unction _validationRules() {
> > š š š š $this->validate = array(
> > š š š š š š 'name' => array(
> > š š š š š š š š 'rule' => 'notEmpty',
> > š š š š š š š š 'message' => __('Name can not be empty', true)
> > š š š š š š ),
>
> > I have a .po file and translated all these strings.
>
> > The project works perfect when I switch the languages, just not for
> > the validation error.
>
> > Has anyone any ideas?

-- 
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: Translate model validation question

2011-10-13 Thread Dr. Loboto
http://book.cakephp.org/view/1230/Localization-in-CakePHP

Reload invalidate() method.

On 13 окт, 18:38, heohni  wrote:
> Hi,
>
> I have this in my app_model.php
> public $validate = array();
>
>     public function __construct($id = false, $table = null, $ds =
> null) {
>         parent::__construct($id, $table, $ds);
>
>         $this->_validationRules();
>     }
>
> And this way I have my model
> unction _validationRules() {
>         $this->validate = array(
>             'name' => array(
>                 'rule' => 'notEmpty',
>                 'message' => __('Name can not be empty', true)
>             ),
>
> I have a .po file and translated all these strings.
>
> The project works perfect when I switch the languages, just not for
> the validation error.
>
> Has anyone any ideas?

-- 
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


Translate model validation question

2011-10-13 Thread heohni
Hi,

I have this in my app_model.php
public $validate = array();

public function __construct($id = false, $table = null, $ds =
null) {
parent::__construct($id, $table, $ds);

$this->_validationRules();
}

And this way I have my model
unction _validationRules() {
$this->validate = array(
'name' => array(
'rule' => 'notEmpty',
'message' => __('Name can not be empty', true)
),

I have a .po file and translated all these strings.

The project works perfect when I switch the languages, just not for
the validation error.

Has anyone any ideas?

-- 
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: Security and Model Validation Questions

2011-08-20 Thread WebbedIT
Glad my past mistakes could be of help to you :P

HTH, Paul

P.S. I'm going to CakeFest Manchester for all 4 days, would love to
know who else is going .. a rare chance for us all to meet up!

On Aug 20, 5:12 am, andrewperk  wrote:
> WebbedIT, you had it correct. Thanks so much.
>
> I fixed the problem, There was never anyone gaining access to my app.
> It was in my paypal processing after a completed payment. I wasn't
> actually confirming that a user had been found before doing the update
> so this was creating a blank user.
>
> Here's the long story:
>
> My client has other products they sell in Paypal using paypal buttons.
> So, after I enabled IPN in their account I just noticed that my IPN
> table was receiving IPN's from my clients other products. Since in my
> app I find the user who made the payment based on a custom field that
> is returned by IPN to my app. When these other orders of my clients
> were being sent to my IPN URL that custom field wasn't available, so
> it wasn't actually finding the user to update to a premium membership
> but it still passed my logic test of being a completed payment. The
> user wasn't ever found. Instead, like you said I was setting the ID of
> the user to update in the controller for a user who wasn't actually
> there and it was creating a blank one and in that same logic it sets
> the premium subscriber field to YES.
>
> I fixed it by just checking that it actually finds a user before doing
> the update.
>
> Thanks so much for pointing that out. I appreciate every ones help.
>
> On Aug 19, 3:43 am, WebbedIT  wrote:
>
>
>
>
>
>
>
> > Are you sure someone is actually gaining access to your database? If
> > they were, I would expect them to do a lot worse than create some
> > blank records in your user table.
>
> > It is possible you have a form somewhere in your app for a model that
> > is related to User, but are not including User.id field in the form.
> > If so when you update that record using this form it will create a
> > blank record in the User table.
>
> > HTH, Paul.
>
> > On Aug 19, 2:56 am, andrewperk  wrote:
>
> > > Hi again, it appears that this did not fix the problem. He's still
> > > gaining database access.
>
> > > I've changed my core.php debug to 0. I also changed the password of my
> > > database. I've checked my server to make sure its not displaying php
> > > errors. I'm using the security component. I'm on Cake 1.3.10. I'm in
> > > the process of upgrading my cake folder to 1.3.11 right now.
>
> > > But yet, even after these changes this person has again somehow gotten
> > > access to my database. He's inserting users with all fields of the
> > > user table set to NULL and marking himself as a premium member(its one
> > > of my fields in the user table). He doesn't give himself a username or
> > > password so he can't actually log in and abuse my system. He's just
> > > got access to my database somehow.
>
> > > I'm not sure how to figure out how he's doing this. Does anyone have
> > > any ideas? If you need me to paste some code please let me know and
> > > I'll provide it, as I'm not sure where the error might lie.
>
> > > Thanks for any help.
>
> > > On Aug 13, 8:57 am, euromark  wrote:
>
> > > > yes, withsecuritycomponent this is not possible.
> > > > but ceeram is right about the password displayed.
>
> > > > On 13 Aug., 01:13, andrewperk  wrote:
>
> > > > > The username and password is specific to just that database luckily.
> > > > > I've changed the information. Thanks Ceeram.
>
> > > > > On Aug 12, 3:51 pm, Ceeram  wrote:
>
> > > > > > with debug on, and there is an error with db connection, it will 
> > > > > > show db
> > > > > > login credentials (this is changed in latest versions), so they 
> > > > > > probably
> > > > > > accessed the db itself, is the user allowed for all hosts on the db 
> > > > > > or just
> > > > > > local?

-- 
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: Security and Model Validation Questions

2011-08-19 Thread andrewperk
WebbedIT, you had it correct. Thanks so much.

I fixed the problem, There was never anyone gaining access to my app.
It was in my paypal processing after a completed payment. I wasn't
actually confirming that a user had been found before doing the update
so this was creating a blank user.

Here's the long story:

My client has other products they sell in Paypal using paypal buttons.
So, after I enabled IPN in their account I just noticed that my IPN
table was receiving IPN's from my clients other products. Since in my
app I find the user who made the payment based on a custom field that
is returned by IPN to my app. When these other orders of my clients
were being sent to my IPN URL that custom field wasn't available, so
it wasn't actually finding the user to update to a premium membership
but it still passed my logic test of being a completed payment. The
user wasn't ever found. Instead, like you said I was setting the ID of
the user to update in the controller for a user who wasn't actually
there and it was creating a blank one and in that same logic it sets
the premium subscriber field to YES.

I fixed it by just checking that it actually finds a user before doing
the update.

Thanks so much for pointing that out. I appreciate every ones help.

On Aug 19, 3:43 am, WebbedIT  wrote:
> Are you sure someone is actually gaining access to your database? If
> they were, I would expect them to do a lot worse than create some
> blank records in your user table.
>
> It is possible you have a form somewhere in your app for a model that
> is related to User, but are not including User.id field in the form.
> If so when you update that record using this form it will create a
> blank record in the User table.
>
> HTH, Paul.
>
> On Aug 19, 2:56 am, andrewperk  wrote:
>
> > Hi again, it appears that this did not fix the problem. He's still
> > gaining database access.
>
> > I've changed my core.php debug to 0. I also changed the password of my
> > database. I've checked my server to make sure its not displaying php
> > errors. I'm using the security component. I'm on Cake 1.3.10. I'm in
> > the process of upgrading my cake folder to 1.3.11 right now.
>
> > But yet, even after these changes this person has again somehow gotten
> > access to my database. He's inserting users with all fields of the
> > user table set to NULL and marking himself as a premium member(its one
> > of my fields in the user table). He doesn't give himself a username or
> > password so he can't actually log in and abuse my system. He's just
> > got access to my database somehow.
>
> > I'm not sure how to figure out how he's doing this. Does anyone have
> > any ideas? If you need me to paste some code please let me know and
> > I'll provide it, as I'm not sure where the error might lie.
>
> > Thanks for any help.
>
> > On Aug 13, 8:57 am, euromark  wrote:
>
> > > yes, withsecuritycomponent this is not possible.
> > > but ceeram is right about the password displayed.
>
> > > On 13 Aug., 01:13, andrewperk  wrote:
>
> > > > The username and password is specific to just that database luckily.
> > > > I've changed the information. Thanks Ceeram.
>
> > > > On Aug 12, 3:51 pm, Ceeram  wrote:
>
> > > > > with debug on, and there is an error with db connection, it will show 
> > > > > db
> > > > > login credentials (this is changed in latest versions), so they 
> > > > > probably
> > > > > accessed the db itself, is the user allowed for all hosts on the db 
> > > > > or just
> > > > > local?

-- 
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: Security and Model Validation Questions

2011-08-19 Thread andrewperk
Also, this is not happening locally when I develop.

I would think if I had a form somewhere creating blank users it should
happen locally as well. This is only happening on my remote server.

I don't know how to fix this. =(

On Aug 19, 9:46 am, andrewperk  wrote:
> Hi WebbedIT, The reason I think someone is having access to my db  is
> that in my user table, I have a field called subscriber(varchar) and
> by default(SQL default) when a user is created this field is populated
> with the word NO in it. The blank user fields that are being created
> have the subscriber field marked as YES.
>
> If my form was doing what you say, shouldn't the subscriber field also
> be marked as NULL? Instead all fields except subscriber are NULL and
> the subscriber fields is marked as YES. The only logic I have that
> messes with the subscriber field is my paypal update which gets the
> user who made the payment and updates their subscriber field to yes.
>
> Thanks.
>
> On Aug 19, 3:43 am, WebbedIT  wrote:
>
> > Are you sure someone is actually gaining access to your database? If
> > they were, I would expect them to do a lot worse than create some
> > blank records in your user table.
>
> > It is possible you have a form somewhere in your app for a model that
> > is related to User, but are not including User.id field in the form.
> > If so when you update that record using this form it will create a
> > blank record in the User table.
>
> > HTH, Paul.
>
> > On Aug 19, 2:56 am, andrewperk  wrote:
>
> > > Hi again, it appears that this did not fix the problem. He's still
> > > gaining database access.
>
> > > I've changed my core.php debug to 0. I also changed the password of my
> > > database. I've checked my server to make sure its not displaying php
> > > errors. I'm using the security component. I'm on Cake 1.3.10. I'm in
> > > the process of upgrading my cake folder to 1.3.11 right now.
>
> > > But yet, even after these changes this person has again somehow gotten
> > > access to my database. He's inserting users with all fields of the
> > > user table set to NULL and marking himself as a premium member(its one
> > > of my fields in the user table). He doesn't give himself a username or
> > > password so he can't actually log in and abuse my system. He's just
> > > got access to my database somehow.
>
> > > I'm not sure how to figure out how he's doing this. Does anyone have
> > > any ideas? If you need me to paste some code please let me know and
> > > I'll provide it, as I'm not sure where the error might lie.
>
> > > Thanks for any help.
>
> > > On Aug 13, 8:57 am, euromark  wrote:
>
> > > > yes, withsecuritycomponent this is not possible.
> > > > but ceeram is right about the password displayed.
>
> > > > On 13 Aug., 01:13, andrewperk  wrote:
>
> > > > > The username and password is specific to just that database luckily.
> > > > > I've changed the information. Thanks Ceeram.
>
> > > > > On Aug 12, 3:51 pm, Ceeram  wrote:
>
> > > > > > with debug on, and there is an error with db connection, it will 
> > > > > > show db
> > > > > > login credentials (this is changed in latest versions), so they 
> > > > > > probably
> > > > > > accessed the db itself, is the user allowed for all hosts on the db 
> > > > > > or just
> > > > > > local?

-- 
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: Security and Model Validation Questions

2011-08-19 Thread andrewperk
Hi WebbedIT, The reason I think someone is having access to my db  is
that in my user table, I have a field called subscriber(varchar) and
by default(SQL default) when a user is created this field is populated
with the word NO in it. The blank user fields that are being created
have the subscriber field marked as YES.

If my form was doing what you say, shouldn't the subscriber field also
be marked as NULL? Instead all fields except subscriber are NULL and
the subscriber fields is marked as YES. The only logic I have that
messes with the subscriber field is my paypal update which gets the
user who made the payment and updates their subscriber field to yes.

Thanks.


On Aug 19, 3:43 am, WebbedIT  wrote:
> Are you sure someone is actually gaining access to your database? If
> they were, I would expect them to do a lot worse than create some
> blank records in your user table.
>
> It is possible you have a form somewhere in your app for a model that
> is related to User, but are not including User.id field in the form.
> If so when you update that record using this form it will create a
> blank record in the User table.
>
> HTH, Paul.
>
> On Aug 19, 2:56 am, andrewperk  wrote:
>
> > Hi again, it appears that this did not fix the problem. He's still
> > gaining database access.
>
> > I've changed my core.php debug to 0. I also changed the password of my
> > database. I've checked my server to make sure its not displaying php
> > errors. I'm using the security component. I'm on Cake 1.3.10. I'm in
> > the process of upgrading my cake folder to 1.3.11 right now.
>
> > But yet, even after these changes this person has again somehow gotten
> > access to my database. He's inserting users with all fields of the
> > user table set to NULL and marking himself as a premium member(its one
> > of my fields in the user table). He doesn't give himself a username or
> > password so he can't actually log in and abuse my system. He's just
> > got access to my database somehow.
>
> > I'm not sure how to figure out how he's doing this. Does anyone have
> > any ideas? If you need me to paste some code please let me know and
> > I'll provide it, as I'm not sure where the error might lie.
>
> > Thanks for any help.
>
> > On Aug 13, 8:57 am, euromark  wrote:
>
> > > yes, withsecuritycomponent this is not possible.
> > > but ceeram is right about the password displayed.
>
> > > On 13 Aug., 01:13, andrewperk  wrote:
>
> > > > The username and password is specific to just that database luckily.
> > > > I've changed the information. Thanks Ceeram.
>
> > > > On Aug 12, 3:51 pm, Ceeram  wrote:
>
> > > > > with debug on, and there is an error with db connection, it will show 
> > > > > db
> > > > > login credentials (this is changed in latest versions), so they 
> > > > > probably
> > > > > accessed the db itself, is the user allowed for all hosts on the db 
> > > > > or just
> > > > > local?

-- 
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: Security and Model Validation Questions

2011-08-19 Thread WebbedIT
Are you sure someone is actually gaining access to your database? If
they were, I would expect them to do a lot worse than create some
blank records in your user table.

It is possible you have a form somewhere in your app for a model that
is related to User, but are not including User.id field in the form.
If so when you update that record using this form it will create a
blank record in the User table.

HTH, Paul.

On Aug 19, 2:56 am, andrewperk  wrote:
> Hi again, it appears that this did not fix the problem. He's still
> gaining database access.
>
> I've changed my core.php debug to 0. I also changed the password of my
> database. I've checked my server to make sure its not displaying php
> errors. I'm using the security component. I'm on Cake 1.3.10. I'm in
> the process of upgrading my cake folder to 1.3.11 right now.
>
> But yet, even after these changes this person has again somehow gotten
> access to my database. He's inserting users with all fields of the
> user table set to NULL and marking himself as a premium member(its one
> of my fields in the user table). He doesn't give himself a username or
> password so he can't actually log in and abuse my system. He's just
> got access to my database somehow.
>
> I'm not sure how to figure out how he's doing this. Does anyone have
> any ideas? If you need me to paste some code please let me know and
> I'll provide it, as I'm not sure where the error might lie.
>
> Thanks for any help.
>
> On Aug 13, 8:57 am, euromark  wrote:
>
>
>
>
>
>
>
> > yes, withsecuritycomponent this is not possible.
> > but ceeram is right about the password displayed.
>
> > On 13 Aug., 01:13, andrewperk  wrote:
>
> > > The username and password is specific to just that database luckily.
> > > I've changed the information. Thanks Ceeram.
>
> > > On Aug 12, 3:51 pm, Ceeram  wrote:
>
> > > > with debug on, and there is an error with db connection, it will show db
> > > > login credentials (this is changed in latest versions), so they probably
> > > > accessed the db itself, is the user allowed for all hosts on the db or 
> > > > just
> > > > local?

-- 
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: Security and Model Validation Questions

2011-08-18 Thread andrewperk
Hi again, it appears that this did not fix the problem. He's still
gaining database access.

I've changed my core.php debug to 0. I also changed the password of my
database. I've checked my server to make sure its not displaying php
errors. I'm using the security component. I'm on Cake 1.3.10. I'm in
the process of upgrading my cake folder to 1.3.11 right now.

But yet, even after these changes this person has again somehow gotten
access to my database. He's inserting users with all fields of the
user table set to NULL and marking himself as a premium member(its one
of my fields in the user table). He doesn't give himself a username or
password so he can't actually log in and abuse my system. He's just
got access to my database somehow.

I'm not sure how to figure out how he's doing this. Does anyone have
any ideas? If you need me to paste some code please let me know and
I'll provide it, as I'm not sure where the error might lie.

Thanks for any help.

On Aug 13, 8:57 am, euromark  wrote:
> yes, withsecuritycomponent this is not possible.
> but ceeram is right about the password displayed.
>
> On 13 Aug., 01:13, andrewperk  wrote:
>
> > The username and password is specific to just that database luckily.
> > I've changed the information. Thanks Ceeram.
>
> > On Aug 12, 3:51 pm, Ceeram  wrote:
>
> > > with debug on, and there is an error with db connection, it will show db
> > > login credentials (this is changed in latest versions), so they probably
> > > accessed the db itself, is the user allowed for all hosts on the db or 
> > > just
> > > local?

-- 
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: Security and Model Validation Questions

2011-08-13 Thread euromark
yes, with security component this is not possible.
but ceeram is right about the password displayed.

On 13 Aug., 01:13, andrewperk  wrote:
> The username and password is specific to just that database luckily.
> I've changed the information. Thanks Ceeram.
>
> On Aug 12, 3:51 pm, Ceeram  wrote:
>
>
>
>
>
>
>
> > with debug on, and there is an error with db connection, it will show db
> > login credentials (this is changed in latest versions), so they probably
> > accessed the db itself, is the user allowed for all hosts on the db or just
> > local?

-- 
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: Security and Model Validation Questions

2011-08-12 Thread andrewperk
The username and password is specific to just that database luckily.
I've changed the information. Thanks Ceeram.

On Aug 12, 3:51 pm, Ceeram  wrote:
> with debug on, and there is an error with db connection, it will show db
> login credentials (this is changed in latest versions), so they probably
> accessed the db itself, is the user allowed for all hosts on the db or just
> local?

-- 
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: Security and Model Validation Questions

2011-08-12 Thread Ceeram
with debug on, and there is an error with db connection, it will show db 
login credentials (this is changed in latest versions), so they probably 
accessed the db itself, is the user allowed for all hosts on the db or just 
local?

-- 
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: Security and Model Validation Questions

2011-08-12 Thread andrewperk
Hi euromark,

Thank you. Thank you for the article.

But I'm already using the Security component to prevent form tampering
and submitting an empty form or modifying the form fields should not
work correct? The security component now prevents all of that?

On Aug 12, 1:57 pm, euromark  wrote:
> debug > 0 is an absolute nogo for productive sites.
>
> but besides that:
> yes, thats possible
> there are several easy ways to bypass the baked actions and validation
>
> the easiest thing is to post empty forms (using firebug its easy to
> remove the inputs or replace them with nonsense).
>
> @seehttp://www.dereuromark.de/2010/09/21/saving-model-data-and-security/
> for details
>
> On 12 Aug., 22:24, andrewperk  wrote:
>
> > Hello,
>
> > I have a cakephp site I'm working on. I have it live on a production
> > server, it's still in development.
>
> > I switched my core.php from production to development to do some
> > testing of things on the live server and forgot to change it back. I
> > left it like this for about a week.
>
> > Apparently someone smart found the website. They didn't do any damage
> > they just kind of let me know I had a bug somewhere.
>
> > They were somehow able to bypass my model validation and register
> > themselves with a NULL username and password and marked themselves as
> > a premium member which can only be done via a paypal payment using web
> > tech nicks paypal plugin. They did this 4 times set username, email,
> > password fields in the DB to NULL and marked themselves as a premium
> > member giving them paid services for free.
>
> >  I'm wondering if while I left the core.php in development mode they
> > got DB access somehow and that's how they did it?
>
> > Here's my basic user validation which ensures a username and valid
> > password and confirmation as well as username uniqueness:
>
> > 'username'=>array(
> >       'Not Empty'=>array(
> >         'rule'=>'notEmpty',
> >         'message'=>'Please enter your desired username.'
> >       ),
> >       'Username 4 length'=>array(
> >         'rule'=>array('minLength', 4),
> >         'message'=>array('Username must be at least 4 characters in
> > length')
> >       ),
> >       'Username can only be alphanumeric'=>array(
> >         'rule'=>'alphaNumeric',
> >         'message'=>'Username can only be letters and numbers.'
> >       ),
> >       'Must be unique'=>array(
> >         'rule'=>'isUnique',
> >         'message'=>'That username is taken, try another.'
> >       )
> >     ),
> >     'email'=>array(
> >       'Not empty'=>array(
> >         'rule'=>'notEmpty',
> >         'message'=>'Please enter your email address.'
> >       ),
> >       'Valid email'=>array(
> >         'rule'=>'email',
> >         'message'=>'This is not a valid email address.'
> >       ),
> >       'Must be unique'=>array(
> >         'rule'=>'isUnique',
> >         'message'=>'That email address is already taken.'
> >       )
> >     ),
> >     'password'=>array(
> >       'Minimum 6 length'=>array(
> >         'rule'=>array('minLength', 6),
> >         'message'=>'Password must be at least 6 characters in length.'
> >       ),
> >       'Passwords must match'=>array(
> >         'rule'=>'matchPasswords',
> >         'message'=>'The passwords do not match.'
> >       )
> >     ),
> >     'ToS'=>array(
> >         'rule'=>'/1/',
> >         'message'=>'You must agree to the terms of service.'
> >     )
>
> > Is there any other way they could have gotten around my model
> > validations? Or did they DB access because I left my core.php in
> > development?
>
> > Thanks.

-- 
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: Security and Model Validation Questions

2011-08-12 Thread euromark
debug > 0 is an absolute nogo for productive sites.

but besides that:
yes, thats possible
there are several easy ways to bypass the baked actions and validation

the easiest thing is to post empty forms (using firebug its easy to
remove the inputs or replace them with nonsense).

@see
http://www.dereuromark.de/2010/09/21/saving-model-data-and-security/
for details


On 12 Aug., 22:24, andrewperk  wrote:
> Hello,
>
> I have a cakephp site I'm working on. I have it live on a production
> server, it's still in development.
>
> I switched my core.php from production to development to do some
> testing of things on the live server and forgot to change it back. I
> left it like this for about a week.
>
> Apparently someone smart found the website. They didn't do any damage
> they just kind of let me know I had a bug somewhere.
>
> They were somehow able to bypass my model validation and register
> themselves with a NULL username and password and marked themselves as
> a premium member which can only be done via a paypal payment using web
> tech nicks paypal plugin. They did this 4 times set username, email,
> password fields in the DB to NULL and marked themselves as a premium
> member giving them paid services for free.
>
>  I'm wondering if while I left the core.php in development mode they
> got DB access somehow and that's how they did it?
>
> Here's my basic user validation which ensures a username and valid
> password and confirmation as well as username uniqueness:
>
> 'username'=>array(
>       'Not Empty'=>array(
>         'rule'=>'notEmpty',
>         'message'=>'Please enter your desired username.'
>       ),
>       'Username 4 length'=>array(
>         'rule'=>array('minLength', 4),
>         'message'=>array('Username must be at least 4 characters in
> length')
>       ),
>       'Username can only be alphanumeric'=>array(
>         'rule'=>'alphaNumeric',
>         'message'=>'Username can only be letters and numbers.'
>       ),
>       'Must be unique'=>array(
>         'rule'=>'isUnique',
>         'message'=>'That username is taken, try another.'
>       )
>     ),
>     'email'=>array(
>       'Not empty'=>array(
>         'rule'=>'notEmpty',
>         'message'=>'Please enter your email address.'
>       ),
>       'Valid email'=>array(
>         'rule'=>'email',
>         'message'=>'This is not a valid email address.'
>       ),
>       'Must be unique'=>array(
>         'rule'=>'isUnique',
>         'message'=>'That email address is already taken.'
>       )
>     ),
>     'password'=>array(
>       'Minimum 6 length'=>array(
>         'rule'=>array('minLength', 6),
>         'message'=>'Password must be at least 6 characters in length.'
>       ),
>       'Passwords must match'=>array(
>         'rule'=>'matchPasswords',
>         'message'=>'The passwords do not match.'
>       )
>     ),
>     'ToS'=>array(
>         'rule'=>'/1/',
>         'message'=>'You must agree to the terms of service.'
>     )
>
> Is there any other way they could have gotten around my model
> validations? Or did they DB access because I left my core.php in
> development?
>
> Thanks.

-- 
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


Security and Model Validation Questions

2011-08-12 Thread andrewperk
Hello,

I have a cakephp site I'm working on. I have it live on a production
server, it's still in development.

I switched my core.php from production to development to do some
testing of things on the live server and forgot to change it back. I
left it like this for about a week.

Apparently someone smart found the website. They didn't do any damage
they just kind of let me know I had a bug somewhere.

They were somehow able to bypass my model validation and register
themselves with a NULL username and password and marked themselves as
a premium member which can only be done via a paypal payment using web
tech nicks paypal plugin. They did this 4 times set username, email,
password fields in the DB to NULL and marked themselves as a premium
member giving them paid services for free.

 I'm wondering if while I left the core.php in development mode they
got DB access somehow and that's how they did it?

Here's my basic user validation which ensures a username and valid
password and confirmation as well as username uniqueness:

'username'=>array(
  'Not Empty'=>array(
'rule'=>'notEmpty',
'message'=>'Please enter your desired username.'
  ),
  'Username 4 length'=>array(
'rule'=>array('minLength', 4),
'message'=>array('Username must be at least 4 characters in
length')
  ),
  'Username can only be alphanumeric'=>array(
'rule'=>'alphaNumeric',
'message'=>'Username can only be letters and numbers.'
  ),
  'Must be unique'=>array(
'rule'=>'isUnique',
'message'=>'That username is taken, try another.'
  )
),
'email'=>array(
  'Not empty'=>array(
'rule'=>'notEmpty',
'message'=>'Please enter your email address.'
  ),
  'Valid email'=>array(
'rule'=>'email',
'message'=>'This is not a valid email address.'
  ),
  'Must be unique'=>array(
'rule'=>'isUnique',
'message'=>'That email address is already taken.'
  )
),
'password'=>array(
  'Minimum 6 length'=>array(
'rule'=>array('minLength', 6),
'message'=>'Password must be at least 6 characters in length.'
  ),
  'Passwords must match'=>array(
'rule'=>'matchPasswords',
'message'=>'The passwords do not match.'
  )
),
'ToS'=>array(
'rule'=>'/1/',
'message'=>'You must agree to the terms of service.'
)


Is there any other way they could have gotten around my model
validations? Or did they DB access because I left my core.php in
development?

Thanks.

-- 
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


Model validation for multiple actions

2010-09-06 Thread amin
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


Model validation for multiple actions

2010-09-06 Thread amin
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


Re: call model validation for multiple actions

2010-09-05 Thread Jeremy Burns | Class Outfit
If you have your validation rules set up in the model, they will automatically 
be triggered each time you do any save action against the model - that is, 
unless you have changed something to prevent it. You don't need to call the 
validate method at all. You can, however, do if ($this->ModelName->validates()) 
as a test before doing the actual save, but that is rarely necessary.

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 3 Sep 2010, at 13:15, 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


call model validation for multiple actions

2010-09-04 Thread amin
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


Model Validation Message

2010-08-04 Thread Miqdad Ali
anybody idea for this
var $validate = array(

  'name' => array(
  'rule' =>
array('custom','/^[A-Z -.]{1,}$/i'),
  'required' => true,
  'message' => 'Please choose
qualifying exam'

   )
)
this is my model for validating name I want to display this message in red
color
pls help.


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


Difference between Model Validation and manually setting error option in a form element

2010-01-28 Thread Imrael
I noticed a strange behaviour today.

I tried to enter some manual validation into a form.
This worked fine, except that the error message was printed out before
the input element:

Please select or
enter a Journal [...]

When I use the Model Validation, the Error Message is appended after
the form element (and with different HTML Code):
Please enter a year between 1000
and 2030


Is there a way to tweak the error field in the form to act like the
normal model validation?

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: Localization for Model validation messages

2009-12-27 Thread euromark
i wouldnt copy it exactly 1:1

translations should never be just "Minimum length of 8 characters"
then you'd need the same text for all other 999 different
character lenghts

better to use sprintf(__(text, true), var1, var2, ..) with %s etc


On 27 Dez., 10:47, Walther  wrote:
> Check here:http://book.cakephp.org/view/133/Multiple-Rules-per-Field
> (at the bottom) for the recommended method of doing it.
>
> On Dec 26, 10:55 am, si-mon  wrote:
>
> > Thanks John. Thanks Euromark. Really helpful...
>
> > On Dec 25, 9:55 pm, John Andersen  wrote:
>
> > > I can't agree, as I prefer to have the model be concerned with model
> > > things (data, retrieval, saving, validation, etc.), and the view
> > > concerned with presenting the data and the related error messages,
> > > including the localization!
>
> > > Usually I only have one form in which data for a specific model is
> > > entered, so the adding a new rule and forgetting to add the
> > > localization in the form, does not become an issue! Also, a change is
> > > always planned - what to add, what to change, etc.
>
> > > But each of us use the technique which we are comfortable with :)
> > >    John
>
> > > On Dec 25, 4:32 pm, euromark  wrote:
>
> > > > i dont like the form-way
> > > > it is quite redundant - if you add a new rule you might forget
> > > > one or two views which would not be helpful
>
> > > > having it all together in the model is in my opinion a cleaner
> > > > approach :)
>
> > > > On 25 Dez., 12:32, John Andersen  wrote:
>
> > > > > Use the form helpers option for the input fields! Look 
> > > > > at:http://book.cakephp.org/view/198/options-error
>
> > > > > Thus you localize in the view - example:
>
> > > > > echo $form->input(
> > > > >    'email',
> > > > >    array(
> > > > >       'label' => __('e-mail address',true),
> > > > >       'error' => array('users_email_rule' => __
> > > > > ('users_email_rule',true) )
> > > > >    )
> > > > > ) ;
>
> > > > > Observe the 'error' option! Here I use it to convert the validation
> > > > > message into the language that the user is viewing the form.
>
> > > > > Enjoy,
> > > > >    John
>
> > > > > On Dec 24, 7:39 pm, si-mon  wrote:
>
> > > > > > Hi All,
>
> > > > > > Is there a way to use localization for validation messages in the
> > > > > > Model $validate array?
>
> > > > > > eg: $validate = array ( 'name' => array('rule'=>'notEmpty',
> > > > > > 'message'=>'Name is mandatory' ));
>
> > > > > > I need the message 'Name is mandatory' in five different languages.
>
> > > > > > In other words: How can we use functions like __('message') like
> > > > > > functions in model?
>
> > > > > > Please help me. Thanks.

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: Localization for Model validation messages

2009-12-27 Thread Walther
Check here: http://book.cakephp.org/view/133/Multiple-Rules-per-Field
(at the bottom) for the recommended method of doing it.

On Dec 26, 10:55 am, si-mon  wrote:
> Thanks John. Thanks Euromark. Really helpful...
>
> On Dec 25, 9:55 pm, John Andersen  wrote:
>
> > I can't agree, as I prefer to have the model be concerned with model
> > things (data, retrieval, saving, validation, etc.), and the view
> > concerned with presenting the data and the related error messages,
> > including the localization!
>
> > Usually I only have one form in which data for a specific model is
> > entered, so the adding a new rule and forgetting to add the
> > localization in the form, does not become an issue! Also, a change is
> > always planned - what to add, what to change, etc.
>
> > But each of us use the technique which we are comfortable with :)
> >    John
>
> > On Dec 25, 4:32 pm, euromark  wrote:
>
> > > i dont like the form-way
> > > it is quite redundant - if you add a new rule you might forget
> > > one or two views which would not be helpful
>
> > > having it all together in the model is in my opinion a cleaner
> > > approach :)
>
> > > On 25 Dez., 12:32, John Andersen  wrote:
>
> > > > Use the form helpers option for the input fields! Look 
> > > > at:http://book.cakephp.org/view/198/options-error
>
> > > > Thus you localize in the view - example:
>
> > > > echo $form->input(
> > > >    'email',
> > > >    array(
> > > >       'label' => __('e-mail address',true),
> > > >       'error' => array('users_email_rule' => __
> > > > ('users_email_rule',true) )
> > > >    )
> > > > ) ;
>
> > > > Observe the 'error' option! Here I use it to convert the validation
> > > > message into the language that the user is viewing the form.
>
> > > > Enjoy,
> > > >    John
>
> > > > On Dec 24, 7:39 pm, si-mon  wrote:
>
> > > > > Hi All,
>
> > > > > Is there a way to use localization for validation messages in the
> > > > > Model $validate array?
>
> > > > > eg: $validate = array ( 'name' => array('rule'=>'notEmpty',
> > > > > 'message'=>'Name is mandatory' ));
>
> > > > > I need the message 'Name is mandatory' in five different languages.
>
> > > > > In other words: How can we use functions like __('message') like
> > > > > functions in model?
>
> > > > > Please help me. Thanks.

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: Localization for Model validation messages

2009-12-26 Thread si-mon
Thanks John. Thanks Euromark. Really helpful...

On Dec 25, 9:55 pm, John Andersen  wrote:
> I can't agree, as I prefer to have the model be concerned with model
> things (data, retrieval, saving, validation, etc.), and the view
> concerned with presenting the data and the related error messages,
> including the localization!
>
> Usually I only have one form in which data for a specific model is
> entered, so the adding a new rule and forgetting to add the
> localization in the form, does not become an issue! Also, a change is
> always planned - what to add, what to change, etc.
>
> But each of us use the technique which we are comfortable with :)
>    John
>
> On Dec 25, 4:32 pm, euromark  wrote:
>
> > i dont like the form-way
> > it is quite redundant - if you add a new rule you might forget
> > one or two views which would not be helpful
>
> > having it all together in the model is in my opinion a cleaner
> > approach :)
>
> > On 25 Dez., 12:32, John Andersen  wrote:
>
> > > Use the form helpers option for the input fields! Look 
> > > at:http://book.cakephp.org/view/198/options-error
>
> > > Thus you localize in the view - example:
>
> > > echo $form->input(
> > >    'email',
> > >    array(
> > >       'label' => __('e-mail address',true),
> > >       'error' => array('users_email_rule' => __
> > > ('users_email_rule',true) )
> > >    )
> > > ) ;
>
> > > Observe the 'error' option! Here I use it to convert the validation
> > > message into the language that the user is viewing the form.
>
> > > Enjoy,
> > >    John
>
> > > On Dec 24, 7:39 pm, si-mon  wrote:
>
> > > > Hi All,
>
> > > > Is there a way to use localization for validation messages in the
> > > > Model $validate array?
>
> > > > eg: $validate = array ( 'name' => array('rule'=>'notEmpty',
> > > > 'message'=>'Name is mandatory' ));
>
> > > > I need the message 'Name is mandatory' in five different languages.
>
> > > > In other words: How can we use functions like __('message') like
> > > > functions in model?
>
> > > > Please help me. Thanks.

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: Localization for Model validation messages

2009-12-25 Thread John Andersen
I can't agree, as I prefer to have the model be concerned with model
things (data, retrieval, saving, validation, etc.), and the view
concerned with presenting the data and the related error messages,
including the localization!

Usually I only have one form in which data for a specific model is
entered, so the adding a new rule and forgetting to add the
localization in the form, does not become an issue! Also, a change is
always planned - what to add, what to change, etc.

But each of us use the technique which we are comfortable with :)
   John

On Dec 25, 4:32 pm, euromark  wrote:
> i dont like the form-way
> it is quite redundant - if you add a new rule you might forget
> one or two views which would not be helpful
>
> having it all together in the model is in my opinion a cleaner
> approach :)
>
> On 25 Dez., 12:32, John Andersen  wrote:
>
> > Use the form helpers option for the input fields! Look 
> > at:http://book.cakephp.org/view/198/options-error
>
> > Thus you localize in the view - example:
>
> > echo $form->input(
> >    'email',
> >    array(
> >       'label' => __('e-mail address',true),
> >       'error' => array('users_email_rule' => __
> > ('users_email_rule',true) )
> >    )
> > ) ;
>
> > Observe the 'error' option! Here I use it to convert the validation
> > message into the language that the user is viewing the form.
>
> > Enjoy,
> >    John
>
> > On Dec 24, 7:39 pm, si-mon  wrote:
>
> > > Hi All,
>
> > > Is there a way to use localization for validation messages in the
> > > Model $validate array?
>
> > > eg: $validate = array ( 'name' => array('rule'=>'notEmpty',
> > > 'message'=>'Name is mandatory' ));
>
> > > I need the message 'Name is mandatory' in five different languages.
>
> > > In other words: How can we use functions like __('message') like
> > > functions in model?
>
> > > Please help me. Thanks.

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: Localization for Model validation messages

2009-12-25 Thread euromark
i dont like the form-way
it is quite redundant - if you add a new rule you might forget
one or two views which would not be helpful

having it all together in the model is in my opinion a cleaner
approach :)


On 25 Dez., 12:32, John Andersen  wrote:
> Use the form helpers option for the input fields! Look 
> at:http://book.cakephp.org/view/198/options-error
>
> Thus you localize in the view - example:
>
> echo $form->input(
>    'email',
>    array(
>       'label' => __('e-mail address',true),
>       'error' => array('users_email_rule' => __
> ('users_email_rule',true) )
>    )
> ) ;
>
> Observe the 'error' option! Here I use it to convert the validation
> message into the language that the user is viewing the form.
>
> Enjoy,
>    John
>
> On Dec 24, 7:39 pm, si-mon  wrote:
>
> > Hi All,
>
> > Is there a way to use localization for validation messages in the
> > Model $validate array?
>
> > eg: $validate = array ( 'name' => array('rule'=>'notEmpty',
> > 'message'=>'Name is mandatory' ));
>
> > I need the message 'Name is mandatory' in five different languages.
>
> > In other words: How can we use functions like __('message') like
> > functions in model?
>
> > Please help me. Thanks.

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: Localization for Model validation messages

2009-12-25 Thread John Andersen
Use the form helpers option for the input fields! Look at:
http://book.cakephp.org/view/198/options-error

Thus you localize in the view - example:

echo $form->input(
   'email',
   array(
  'label' => __('e-mail address',true),
  'error' => array('users_email_rule' => __
('users_email_rule',true) )
   )
) ;

Observe the 'error' option! Here I use it to convert the validation
message into the language that the user is viewing the form.

Enjoy,
   John

On Dec 24, 7:39 pm, si-mon  wrote:
> Hi All,
>
> Is there a way to use localization for validation messages in the
> Model $validate array?
>
> eg: $validate = array ( 'name' => array('rule'=>'notEmpty',
> 'message'=>'Name is mandatory' ));
>
> I need the message 'Name is mandatory' in five different languages.
>
> In other words: How can we use functions like __('message') like
> functions in model?
>
> Please help me. Thanks.

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: Localization for Model validation messages

2009-12-24 Thread euromark
put this in your app_model.php


/**
 * Overrides the Core invalidate function from the Model class
 * with the addition to use internationalization (I18n and L10n)
 * @param string $field Name of the table column
 * @param mixed $value The message or value which should be returned
 * 2009-07-27 ms
 */
function invalidate($field, $value = null) {
if (!is_array($this->validationErrors)) {
$this->validationErrors = array();
}
if(empty($value)) {
$value = true;
}
if (is_array($value)) {
if (count($value) > 2) { # string %s %s string, trans1, 
trans2
$translatedValue = sprintf(__($value[0], true), 
$value[1], $value
[2]);
} else { # string %s string, trans1
$translatedValue = sprintf(__($value[0], true), 
$value[1]);
}
$this->validationErrors[$field] = $translatedValue;
} else {
$this->validationErrors[$field] = __($value, true);
}
}

i even added an array functionality to use
message = array('at least % chars', 255)
etc


On 24 Dez., 18:39, si-mon  wrote:
> Hi All,
>
> Is there a way to use localization for validation messages in the
> Model $validate array?
>
> eg: $validate = array ( 'name' => array('rule'=>'notEmpty',
> 'message'=>'Name is mandatory' ));
>
> I need the message 'Name is mandatory' in five different languages.
>
> In other words: How can we use functions like __('message') like
> functions in model?
>
> Please help me. Thanks.

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


Localization for Model validation messages

2009-12-24 Thread si-mon
Hi All,

Is there a way to use localization for validation messages in the
Model $validate array?

eg: $validate = array ( 'name' => array('rule'=>'notEmpty',
'message'=>'Name is mandatory' ));

I need the message 'Name is mandatory' in five different languages.

In other words: How can we use functions like __('message') like
functions in model?

Please help me. Thanks.

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
-~--~~~~--~~--~--~---



Model validation on unit testing

2009-06-07 Thread williamn

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: Using dynamic values in model validation

2008-12-25 Thread Adam Royle

Controllers talk to models, not the other way round, so you would need
to call a method in your model from your controllers, passing the
params as necessary.

On Dec 23, 8:52 am, gearvOsh  wrote:
> No not that. In the models beforeValidate() is it possible for me to
> do like $controller->params?
>
> UsersController -> User Model
>
> So in User::beforeValidate() can I get UsersControllers params, is
> basically what im asking?
--~--~-~--~~~---~--~~
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: Using dynamic values in model validation

2008-12-22 Thread gearvOsh

No not that. In the models beforeValidate() is it possible for me to
do like $controller->params?

UsersController -> User Model

So in User::beforeValidate() can I get UsersControllers params, is
basically what im asking?
--~--~-~--~~~---~--~~
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: Using dynamic values in model validation

2008-12-22 Thread Adam Royle

I don't really understand your question... are you asking if you can
see what data is going to be saved from inside the beforeValidate()
method?

If so, look at  $this->data

Cheers,
Adam



On Dec 22, 8:20 pm, gearvOsh  wrote:
> Thanks, also is there a way I can get the parent controller data as
> well?
--~--~-~--~~~---~--~~
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: Using dynamic values in model validation

2008-12-22 Thread gearvOsh

Thanks, also is there a way I can get the parent controller data as
well?
--~--~-~--~~~---~--~~
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: Using dynamic values in model validation

2008-12-21 Thread Adam Royle

When defining class properties you can't use expressions - only data
structures, so you need to populate the $validate array dynamically
inside the model. You can do this in beforeValidate() method in your
model, but be sure to return true.

beforeValidate() {
  $this->validate['fieldName'] = array('between' => array(...
etc ...));
  return true;
}

Cheers,
Adam

On Dec 22, 4:57 pm, gearvOsh  wrote:
> Is there a way to use dynamic variables within the Model validation,
> an example below.
>
> 'between' => array(
>         'rule' => array('between', $passMin, $passMax),
>         'message' => 'Password must be between '. $passMin .' and '. $passMax
> )
>
> I have an array of config settings that I would like to use here, but
> am lost on a way to do this.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Using dynamic values in model validation

2008-12-21 Thread gearvOsh

Is there a way to use dynamic variables within the Model validation,
an example below.

'between' => array(
'rule' => array('between', $passMin, $passMax),
'message' => 'Password must be between '. $passMin .' and '. $passMax
)

I have an array of config settings that I would like to use here, but
am lost on a way to do this.
--~--~-~--~~~---~--~~
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: Explanation for model validation on parameter in conjunction with required = true [SOLVED]

2008-12-13 Thread mr_timp

Hi Adam,

Awesome!  Exactly the kind of feedback I was looking for.  Your right
I'm probably basing my design on older ways of doing things, your
example is much less complicated and easier to read.

Thanks for your feedback!
--~--~-~--~~~---~--~~
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: Explanation for model validation on parameter in conjunction with required = true

2008-12-13 Thread Adam Royle

Hi Mr Timp,

Yes, your example looks a bit old/odd. The "correct" equivalent of :

$this->User->data = $this->data;

is this:

$this->User->set($this->data);

This will ensure $this->User->id is updated with the correct value.

However, having said that, most of the code you've got seems unneeded.
Replace with something like this, which automatically calls set() and
validates().

function edit() {
if (!empty($this->data)) {
if ($this->User->save($this->data)) {
$this->Session->setFlash('Your details have been 
updated');
$this->redirect('index');
} else {
$this->Session->setFlash('There was a problem updating 
your
details, please try again shortly');
}
}
}

On Dec 14, 7:42 am, mr_timp  wrote:
> Hi There,
>
> Problem solved.  $this->User->id was unset inside the controller -
> which is kinda weird.  I have fixed it by doing the following:
>
> $this->User->id = $this->data["User"]["id"];
>
> Does it seems odd that I should have to do that?  The example of code
> I'm using was taken from a supposed working application (maybe it was
> written for Cake 1.1 and I'm using 1.2)?.
>
> Cheers
--~--~-~--~~~---~--~~
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: Explanation for model validation on parameter in conjunction with required = true

2008-12-13 Thread mr_timp

Hi There,

Problem solved.  $this->User->id was unset inside the controller -
which is kinda weird.  I have fixed it by doing the following:

$this->User->id = $this->data["User"]["id"];

Does it seems odd that I should have to do that?  The example of code
I'm using was taken from a supposed working application (maybe it was
written for Cake 1.1 and I'm using 1.2)?.

Cheers
--~--~-~--~~~---~--~~
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: Explanation for model validation on parameter in conjunction with required = true

2008-12-13 Thread mr_timp

Hi again,

I have managed to track back what I think the problem is but I'm
having a hard time thinking this is an issue inside Cake given the
number of users who are using the on parameter. If I add $this->id =
[the id of my user] as the first line inside cake/libs/model/model.php
in the invalidFields method the validation works as intended (i.e. if
the record already exists and on = create and required = true then the
rule is skipped, if the record exists and on = update and required =
true the rule is validate.

How I'm calling the validation from inside my controller is as
follows:

// pass the posted data into the user object
$this->User->data = $this->data;

// validate the user details
if ($this->User->validates()) {
// save the user data and redirect
if ($this->User->save($this->data)) {
$this->set("successMessage",
"Your details have been updated.");
} else {
$this->set("errorMessage",
"There was a problem updating your details, please try again
shortly.");
}
} else {
$this->validateErrors($this->User);
}

I notice the $this->User->validates() has $this->id empty but when
$this->validateErrors($this->User) is called the $this->id = is set.

I suspect I'm going about something the wrong way!

Cheers
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Explanation for model validation on parameter in conjunction with required = true

2008-12-12 Thread mr_timp

Hi,

Can someone explain how the on create/update works in conjuncation
with required = true in a model?

Looking at the documentation on the cake web site it indicates that if
you have on create set the rule should be ignored if the action is an
update (and vice versa) but when required = true is set on the same
validation rule it seems that required = true overrides and forces the
validation and ignores the on create / update.

Cheers
--~--~-~--~~~---~--~~
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: All model validation failing when required => true set [SOLVED]

2008-12-12 Thread mr_timp

Typical - looks like I found the answer shortly after posting ;)

Anyway hopefully this will help anyone who has a similar issue:

http://cakebaker.42dh.com/2008/11/05/the-modelvalidates-trap/

http://cakebaker.42dh.com/2007/01/06/parameter-for-modelvalidates-is-now-deprecated/

I was passing $this->data through in the validates method from the
controller which is no deprecated.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



All model validation failing when required => true set

2008-12-12 Thread mr_timp

Hi,

There is probably something very simple that I'm doing wrong but since
adding required => true to the validate array for my User model I'm
having validation fail for all validation rules with this parameter in
the array.  An example of my validation array is below:

var $validate = array (
"username" => array (
"myFunction" => array(
"rule" => array("myFunction",
"username"),
"message" => "Username must be between
3 and 20 characters long"),
"isUnique" => array (
"rule" => array("isUnique",
"username"),
"message" => "The username you have
entered has already been registered.")),
"first_name" => array (
"exists" => array (
"required" => true,
"rule" => array("minLength", 2),
"message" => "Your first name must be
more than 2 characters long.")),
"last_name" => array (
"exists" => array (
"required" => true,
"rule" => array("minLength", 2),
"message" => "Your last name must be
more than 2 characters long.")));

I have confirmed there are no PHP errors in the model, have cleared
out the cake cache and still no joy.  I put a function into the
username validation (myFunction) and did an exit; in the function to
see if its being called and its not even being called.  Its like there
is no data being passed to the model?

Any ideas on what I'm 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 
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
-~--~~~~--~~--~--~---



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

2008-11-13 Thread leberle

Hi guys,

I've a confusing problem here:

my model:

--

class MenuStructure extends AppModel
{
var $validate   =   array('root_struct_id'  => array('required' => 
array
(true)),
'parent_struct_id'  => 
array('required' => array(true)),
'struct_id' 
=> array('required' => array(true)),
'file_name' 
=> array('required' => array(true))
);
}

--

in the controller i call:

if ($this->RequestHandler->isPost())
{
   $this->MenuStructure->create($this->data);
   if ($this->MenuStructure->validates() && $this->AnotherModelBla-
>validates())
   {
  $this->MenuStructure->save($this->data);
   }
}

-
$this->data:

Array
(

[MenuStructure] => Array
(
[root_struct_id] => 1
[struct_id] => 4
[parent_struct_id] => 1
[navi_level] => 1
[file_name] => fghf.test
)

[AnotherModelBla] => Array
(
[... some stuff here ...]
)
)



after spending some time i found out that MenuStructure fails to
validate...
As you can see, all required fields for MenuStructure are set...after
some debugging in cakes core i found that the 'blank' rule is
triggered on MenuStructure->validates() and, of course, fails, as the
fields are not blank...so, the question is: why does is the blank-rule
triggered? And how can i avoid it without changing the cakecore?

and btw: in cake/libes/model/model.php, line 2151 (RC2), line 2202
(RC3):
$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 ?






--~--~-~--~~~---~--~~
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: Selective field model validation

2008-08-18 Thread francky06l

Check carefully the meaning of "required" versus "notEmpty" (or '/\S
+/') in validation  ("required" makes the field mandatory -- but can
be empty -- every time single time you call validation, whether the
field is in a form or not).
Some usage of "on" => "create" might also help.

hth

On Aug 18, 9:55 pm, AD7six <[EMAIL PROTECTED]> wrote:
> On Aug 18, 9:47 pm, David Yell <[EMAIL PROTECTED]> wrote:
>
> > This was solved in #cakephp
> > By using $this->Model->validates($this->data['Model']['field']
>
> > So big thanks to penfold_99 for sorting this for me, thanks!
>
> That reminds me of the time someone "optimized" my code by commenting
> out all the code that did anything...
--~--~-~--~~~---~--~~
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: isUnique model validation 'on create' not working?

2008-08-18 Thread Zoltan

Problem turned out to be I had taken the 'id' field out of the
edit.ctp file.  Put it back in, and everything worked fine.

Zoltan

On Aug 18, 1:38 pm, haj <[EMAIL PROTECTED]> wrote:
> I know I'm not answering to the question but a field that needs to be
> unique generally hold the same requirement on an edit?
> For the real answer, it's working here. Sorry for not helping..
--~--~-~--~~~---~--~~
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: Selective field model validation

2008-08-18 Thread AD7six



On Aug 18, 9:47 pm, David Yell <[EMAIL PROTECTED]> wrote:
> This was solved in #cakephp
> By using $this->Model->validates($this->data['Model']['field']
>
> So big thanks to penfold_99 for sorting this for me, thanks!

That reminds me of the time someone "optimized" my code by commenting
out all the code that did anything...
--~--~-~--~~~---~--~~
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: Selective field model validation

2008-08-18 Thread David Yell

This was solved in #cakephp
By using $this->Model->validates($this->data['Model']['field']

So big thanks to penfold_99 for sorting this for me, thanks!

On Aug 18, 3:26 pm, David Yell <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've been doing some work with my users model and I got to a stage
> where I was creating a method to change a users password to avoid the
> default edit screen from having a populated password and such. Either
> way I ended up with a change_password method and view, this works
> great.
>
> On this page I have two password fields which are checked using a
> custom match rule in my model btw. Then if they pass validation I copy
> one into the password field and save it. The validation is called
> using $this->User->validates() in the controller.  But I was trying to
> validate the password and my model was throwing all kinds of strange
> errors. When I finally dropped in a die(pr($this->User->invalidFields())); 
> into my controller it was showing that all the
>
> other fields, which were marked as required were also being validated.
>
> I got around it by adding the fields as hidden to the form and
> submitting it.
>
> The main question is, is there a way to pass any field list into
> validates or create a validateFields() which takes an array of fields
> to validate? Is this possible? My colleague tells me that I should
> really be creating a passwords model and such and then relating it to
> my User but this seems a little overkill.
>
> In a similar circumstance which I just arrived at again, I am
> forwarding a job to a friend via email and I would like to validate
> the email field against the model before sending the email. Again I
> can't validate just this one field without validating the whole model.
> Yet again, should I be creating a ForwardtoFriend model with no table
> and it's own controller to do this and then associate it with the
> Vacancy?
>
> It seems to me that it might be a bit of a hacky shortcut to be able
> to specify which model fields you want to validate, but one that would
> be super handy, or am I missing the point here? (which is entirely
> possible ;p)
>
> Ta,
> Dave
--~--~-~--~~~---~--~~
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: isUnique model validation 'on create' not working?

2008-08-18 Thread haj

I know I'm not answering to the question but a field that needs to be
unique generally hold the same requirement on an edit?
For the real answer, it's working here. Sorry for not helping..
--~--~-~--~~~---~--~~
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: Selective field model validation

2008-08-18 Thread teknoid

I would suggest to carefully read the manual, where it talks about
data validation ;)

On Aug 18, 10:26 am, David Yell <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've been doing some work with my users model and I got to a stage
> where I was creating a method to change a users password to avoid the
> default edit screen from having a populated password and such. Either
> way I ended up with a change_password method and view, this works
> great.
>
> On this page I have two password fields which are checked using a
> custom match rule in my model btw. Then if they pass validation I copy
> one into the password field and save it. The validation is called
> using $this->User->validates() in the controller.  But I was trying to
> validate the password and my model was throwing all kinds of strange
> errors. When I finally dropped in a die(pr($this->User->invalidFields())); 
> into my controller it was showing that all the
>
> other fields, which were marked as required were also being validated.
>
> I got around it by adding the fields as hidden to the form and
> submitting it.
>
> The main question is, is there a way to pass any field list into
> validates or create a validateFields() which takes an array of fields
> to validate? Is this possible? My colleague tells me that I should
> really be creating a passwords model and such and then relating it to
> my User but this seems a little overkill.
>
> In a similar circumstance which I just arrived at again, I am
> forwarding a job to a friend via email and I would like to validate
> the email field against the model before sending the email. Again I
> can't validate just this one field without validating the whole model.
> Yet again, should I be creating a ForwardtoFriend model with no table
> and it's own controller to do this and then associate it with the
> Vacancy?
>
> It seems to me that it might be a bit of a hacky shortcut to be able
> to specify which model fields you want to validate, but one that would
> be super handy, or am I missing the point here? (which is entirely
> possible ;p)
>
> Ta,
> Dave
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



isUnique model validation 'on create' not working?

2008-08-18 Thread Zoltan

In my model I'm doing something like:

var $validate = array(
'slug' => array('rule' => 'isUnique', 'on' => 'create', 
'message' =>
'This title slug has already been taken.'),
'venue_type_id' => array('numeric'),...

Creating a new record works fine.
Now the problem is it is doing the validation again when I edit the
record and save. It does the validation which of course fails (there
is 1 row with this same slug- the record i just edited)

What am I missing?

Zoltan
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Selective field model validation

2008-08-18 Thread David Yell

Hi,

I've been doing some work with my users model and I got to a stage
where I was creating a method to change a users password to avoid the
default edit screen from having a populated password and such. Either
way I ended up with a change_password method and view, this works
great.

On this page I have two password fields which are checked using a
custom match rule in my model btw. Then if they pass validation I copy
one into the password field and save it. The validation is called
using $this->User->validates() in the controller.  But I was trying to
validate the password and my model was throwing all kinds of strange
errors. When I finally dropped in a die(pr($this->User-
>invalidFields())); into my controller it was showing that all the
other fields, which were marked as required were also being validated.

I got around it by adding the fields as hidden to the form and
submitting it.

The main question is, is there a way to pass any field list into
validates or create a validateFields() which takes an array of fields
to validate? Is this possible? My colleague tells me that I should
really be creating a passwords model and such and then relating it to
my User but this seems a little overkill.

In a similar circumstance which I just arrived at again, I am
forwarding a job to a friend via email and I would like to validate
the email field against the model before sending the email. Again I
can't validate just this one field without validating the whole model.
Yet again, should I be creating a ForwardtoFriend model with no table
and it's own controller to do this and then associate it with the
Vacancy?

It seems to me that it might be a bit of a hacky shortcut to be able
to specify which model fields you want to validate, but one that would
be super handy, or am I missing the point here? (which is entirely
possible ;p)

Ta,
Dave
--~--~-~--~~~---~--~~
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: Use localization in model validation

2008-07-11 Thread Alessandro Daducci

Sorry, you're right! I confused my code while I rewrite it to adapt to
Emilio's case. I just used the trick you cited in yout post (about
__contruct(...) method). It was a very nice solution!

But I still understand one point: you told that in Changeset 5818 that
problem was fixed. But I still have the same problem in RC2 version.
What is wrong?

Sorry my my stupid questions, but I'm a newbie with cakephp...

Alessandro

On 10 Lug, 19:28, francky06l <[EMAIL PROTECTED]> wrote:
> @Allessandro, that would not work, you can't initialize model variable
> with a function call.
>
> @Emilio, I did post a ticket on this a while ago with a solution (as
> you described), it has been introduced and removed after (probably
> because it does not cover all needs etc..). I end up writing the
> invalidFields method in app_model, taking over the core method.
>
> http://groups.google.com/group/cake-php/browse_thread/thread/fa32c81a...
>
> hth
>
> On Jul 10, 4:43 pm, Alessandro Daducci <[EMAIL PROTECTED]>
> wrote:
>
> > Hi Emilio!
>
> > > I'll ilustrate the problem with an example, I want to make something
> > > like this:
>
> > > 
> > >    var $validate = array
> > >    (
> > >            "status" => array
> > >            (
> > >                    "rule" => "numeric",
> > >                    "rule" => array ("range", -1, 101),
> > >                    "message" => "error_task_status",
> > >            ),
> > >    );
> > > 
>
> > > If you see the message for the error on validation, you see
> > > "error_task_status", the idea is that the model calls
> > > __("error_task_status") for the message instead of printing
> > > "error_task_status" directly.
>
> > I don't know if I understood properly, but I usually do this way:
>
> > var $validate = array
> > (
> >         "status" => array
> >         (
> >                 "rule" => "numeric",
> >                 "rule" => array ("range", -1, 101),
> >                 "message" => __("error_task_status",true),
> >         ),
> > );
>
> > This way, you can perform translation automatically!

--~--~-~--~~~---~--~~
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: Use localization in model validation

2008-07-11 Thread Alessandro Daducci

Sorry, You're right! I confused my code with the one that was in your
old post you cited about __contruct(...).
I used that trick, it was great!

But I don't understand: you told that in Changeset 5815 that problem
was fixed, but I still have it in my 1.2 RC2 version. What's wrong?

Sorry for my stupid questions, but I'm a newbie...

Alessandro


On 10 Lug, 19:28, francky06l <[EMAIL PROTECTED]> wrote:
> @Allessandro, that would not work, you can't initialize model variable
> with a function call.
>
> @Emilio, I did post a ticket on this a while ago with a solution (as
> you described), it has been introduced and removed after (probably
> because it does not cover all needs etc..). I end up writing the
> invalidFields method in app_model, taking over the core method.
>
> http://groups.google.com/group/cake-php/browse_thread/thread/fa32c81a...
>
> hth
>
> On Jul 10, 4:43 pm, Alessandro Daducci <[EMAIL PROTECTED]>
> wrote:
>
> > Hi Emilio!
>
> > > I'll ilustrate the problem with an example, I want to make something
> > > like this:
>
> > > 
> > >    var $validate = array
> > >    (
> > >            "status" => array
> > >            (
> > >                    "rule" => "numeric",
> > >                    "rule" => array ("range", -1, 101),
> > >                    "message" => "error_task_status",
> > >            ),
> > >    );
> > > 
>
> > > If you see the message for the error on validation, you see
> > > "error_task_status", the idea is that the model calls
> > > __("error_task_status") for the message instead of printing
> > > "error_task_status" directly.
>
> > I don't know if I understood properly, but I usually do this way:
>
> > var $validate = array
> > (
> >         "status" => array
> >         (
> >                 "rule" => "numeric",
> >                 "rule" => array ("range", -1, 101),
> >                 "message" => __("error_task_status",true),
> >         ),
> > );
>
> > This way, you can perform translation automatically!

--~--~-~--~~~---~--~~
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: Use localization in model validation

2008-07-10 Thread francky06l

@Allessandro, that would not work, you can't initialize model variable
with a function call.

@Emilio, I did post a ticket on this a while ago with a solution (as
you described), it has been introduced and removed after (probably
because it does not cover all needs etc..). I end up writing the
invalidFields method in app_model, taking over the core method.

http://groups.google.com/group/cake-php/browse_thread/thread/fa32c81acc043eef/6a49c6d9fdc6f158?lnk=st&q=#6a49c6d9fdc6f158

hth

On Jul 10, 4:43 pm, Alessandro Daducci <[EMAIL PROTECTED]>
wrote:
> Hi Emilio!
>
>
>
> > I'll ilustrate the problem with an example, I want to make something
> > like this:
>
> > 
> >var $validate = array
> >(
> >"status" => array
> >(
> >"rule" => "numeric",
> >"rule" => array ("range", -1, 101),
> >"message" => "error_task_status",
> >),
> >);
> > 
>
> > If you see the message for the error on validation, you see
> > "error_task_status", the idea is that the model calls
> > __("error_task_status") for the message instead of printing
> > "error_task_status" directly.
>
> I don't know if I understood properly, but I usually do this way:
>
> var $validate = array
> (
> "status" => array
> (
> "rule" => "numeric",
> "rule" => array ("range", -1, 101),
> "message" => __("error_task_status",true),
> ),
> );
>
> This way, you can perform translation automatically!
--~--~-~--~~~---~--~~
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: Use localization in model validation

2008-07-10 Thread Alessandro Daducci



Hi Emilio!

> I'll ilustrate the problem with an example, I want to make something
> like this:
>
> 
>   var $validate = array
>   (
>   "status" => array
>   (
>   "rule" => "numeric",
>   "rule" => array ("range", -1, 101),
>   "message" => "error_task_status",
>   ),
>   );
> 
>
> If you see the message for the error on validation, you see
> "error_task_status", the idea is that the model calls
> __("error_task_status") for the message instead of printing
> "error_task_status" directly.
>

I don't know if I understood properly, but I usually do this way:

var $validate = array
(
"status" => array
(
"rule" => "numeric",
"rule" => array ("range", -1, 101),
"message" => __("error_task_status",true),
),
);

This way, you can perform translation automatically!

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Use localization in model validation

2008-07-10 Thread Emilio González Montaña

Hello,

I'm newie, I've a problem (and a solution) for use localization in
variable $validate in models.

I'll ilustrate the problem with an example, I want to make something
like this:


var $validate = array
(
"status" => array
(
"rule" => "numeric",
"rule" => array ("range", -1, 101),
"message" => "error_task_status",
),
);


If you see the message for the error on validation, you see
"error_task_status", the idea is that the model calls
__("error_task_status") for the message instead of printing
"error_task_status" directly.

I've searched into "Model" class, and I've located this section of
code (at line 2164 in "invalidFields" method):

if (isset($validator['message'])) {
$message = $validator['message'];
} else {
$message = __('This field cannot be 
left blank', true);
}


And I've changed the code to this:

if (isset($validator['message'])) {
$validator['message'] = __ 
($validator['message'], true);
$message = $validator['message'];
} else {
$message = __('This field cannot be 
left blank', true);
}


With this I've found a solution to the problem!.

How can I propose this change to be included into the developmento of
CakePHP???

Thank's a lot for your effort!!!

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



model validation rules order ?

2008-07-06 Thread Dia

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

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
-~--~~~~--~~--~--~---



Model Validation Rule Builder

2008-07-04 Thread Eric

I created a new way of creating validation rules for models, which I
think is kind of slick, but I don't really think the way I have it
working is very "cake-like" and I need some advice on how best it
should be implemented.

Right now in a model I am doing the following to add my RuleBuilder

addRule(new AlphaNumSpaceRule(true, false));

$field_contactName = new ValidationField('contact_name');
$field_contactName->addRule(new AlphaNumSpaceRule(true, false));

$field_phoneNumber = new ValidationField('contact_number');
$field_phoneNumber->addRule(new PhoneNumberRule());

$this->validate = array_merge($field_name-
>getFieldAsArray(),
  
$field_contactName->getFieldAsArray(),
  
$field_phoneNumber->getFieldAsArray());
}

What the code is doing is really just building the validates array by
using the builder design pattern. The good part is that adding
validation rules to your model is easy, it is simple to add multiple
validation rules to a field, and any custom validation rules (i.e. the
AlphaNumSpaceRule) you create are shared among all of the models.

My question is, should I be using a behavior, or is it ok, from a cake
perspective, to just go with my current implementation?

BTW, I think I can use $array1 += $array2 etc... instead of
array_merge which should help performance but I have not tried it yet.

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

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
-~--~~~~--~~--~--~---



  1   2   >