Hi Sun,

Please send your replies to the list.

I think you need to read through the book again to understand how to  
properly use validation rules.
http://book.cakephp.org/view/127/One-Rule-Per-Field

Chrs,
Dav

On 12 Nov 2008, at 16:42, sun wrote:

> Thanks for consider my request,
>   I am asking abt how to validate the empty fields ? consider three
> input text fields and one file upload field. if i click the submit
> button directly with out give any values to the appropriate fields,,
> the error message will be shown  but  no one displayed  so tell how to
> solve this?
>
> Test module:
>       class Test extends Appmodel{
>               var $name = 'Test';
>               var $validate = array(
>                     'name'=>array(
>                                       VALID_NOT_EMPTY,
>                                       ),
>                      'mark1'=>array(
>                               VALID_NOT_EMPTY,
>                               array(
>                                       'rule'=>'numeric',
>                               'required'=>'true',
>                                       )
>                       ),
>                       'mark2'=>array(
>                               VALID_NOT_EMPTY,
>                               array(
>                                       'rule'=>'numeric',
>                               'required'=>'true',
>                                       )
>                       ),
>                 'photo' => array(
>                        VALID_NOT_EMPTY,
>                        array(
>                                       'required'=>'true',
>                                       )
>                       )
>       );
>               function validate($ary_test_info){
>                       $ary_error = array();
>                       for($i=0; $i<1; $i++){
>                       if( 
> $this->isEmpty($ary_test_info['Test']['photo'][$i]['name'])||
>                               
> $this->isEmpty($ary_test_info['Test']['name'][$i])||
>                           
> $this->isEmpty($ary_test_info['Test']['mark1'][$i])||
>                           
> $this->isEmpty($ary_test_info['Test']['mark2'][$i])){
>
>                                       if 
> ($this->isEmpty($ary_test_info['Test']['name'][$i])){
>                                               $ary_error['name'][$i] = 
> 'Please enter  name';
>                                       }
>                                       if 
> ($this->isEmpty($ary_test_info['Test']['mark1'][$i])){
>                                               $ary_error['mark1'][$i] = 
> 'Please enter mark1';
>                                       }
>                                       if 
> ($this->isEmpty($ary_test_info['Test']['mark2'][$i])){
>                                               $ary_error['mark2'][$i] = 
> 'Please enter mark2';
>                                       } elseif 
> (strlen($ary_test_info['Test']['photo'][$i]['name'])>4){
>                                               if ( 
> $this->isEmpty($ary_test_info['Test']['photo'][$i] 
> ['name']))
> {
>                                                       $ary_error[$i]['photo'] 
> = 'Please select an jpg file';
>                                               }
>                                       }
>
>                               } else{
>
>                                       }
>                               return $ary_error;
>               }
>       }
>       function isEmpty($str_data){
>               if (trim($str_data) == ""){
>                       return true;
>                }else{
>                 return false;
>               }
>       }
> }
> ?>
>
> with regards
> sundar


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

Reply via email to