Hi,

I have a problem to obtain translated error messages when I validate
dates.

I have the following:

  - a model "Member" with the following validation rules (I use the
Multivalidatable behavior) :

public $validationSets = array(
                'signUp' => array(
                    'gender' => array(
                                'notEmpty' => array(
                                        'rule' => 'notEmpty',
                                        'required' => true
                            )
                        ),
                    'first_name' => array(
                                'notEmpty' => array(
                                        'rule' => 'notEmpty',
                                    'required' => true
                            )
                        ),
                    'last_name' => array(
                                'notEmpty' => array(
                                        'rule' => 'notEmpty',
                                    'required' => true
                            )
                        ),
                        'birth_date' => array(
                                'date' => array(
                                    'rule' => 'date'
                            ),
                                'notEmpty' => array(
                                        'rule' => 'notEmpty',
                                    'required' => false,
                                'allowEmpty' => false
                            )
                        ),
                        ...
  - My input generated with the following code:
                                              //Member's birth date
                                                e($form->input('birth_date', 
array(
                                                                    'label' => 
__('label_birth_date', true),
                                                                    'div' => 
array('class' => 'form-line clearfix'),
                                                                        
'before' => '<div class="clearfix">',
                                                                        
'between' => '<div class="form-field">',
                                                                        'after' 
=> '</div></div>',
                                                                        'error' 
=> array(
                                                                                
'date' => __('error_invalid_date', true),
                                                                        
'notEmpty' => __('error_birth_date_required', true)
                                                                        ),
                                                                    'minYear'=> 
date('Y') - 100,
                                                                    'maxYear' 
=> date('Y') - 18,
                                                                    
'dateFormat' => 'DMY',
                                                                        'empty' 
=> true
                                                                )
                                                    )
                                                );

  - in my controller:
      //Define validation rules for each model.
        $this->Member->setValidation('signUp');

        //Data posted.
        if (!empty($this->data)) {
            //Sanitize data.
            Sanitize::clean($this->data);
            //Populate member and email models.
            $this->Member->set($this->data);
             .....

Logically the birth date field is required but as you can see my rule,
I set required to false and allowEmpty to false. This because it is
the unique way I can obtain error messages translated correctly.

I debug this during a moment and I found something strange: if I
display $this-data before $this->Member->set($this->data), I have
that:

array(
['Member'] => array(
  ....,
  ['birth_date'] =>
    array(
      ['day'] => ''
      ['month'] => ''
      ['year'] => ''
    )
  )
)

Now If I debug $this->data to the end of the set method, I have that:
array(
['Member'] => array(
  ....,
  ['birth_date'] => null
)

The "set" method seems to modify the $this->data array and is the
origin of the problem of translation for error messages.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to