2015-06-27 2 views
-1

validates() получение не удалось, но validationErrors пуст в CakePHP 2.x, даже у меня есть пользователь unlockedActions для этого метода, но все еще получаю эту ошибку, вставляя ее рабочий тон. Только редактирование не работает.CakePHP - подтверждение возврата false

Это мой код контроллера:

if (!empty($this->data['UserProfileName']['new']['new_profile_id'])){   
    // $this->data['UserProfileName']['old_profile_id'] = $this->data['UserProfileName']['profile_id']; 
    $new_data['UserProfileName']['profile_id'] = $this->data['UserProfileName']['new']['new_profile_id']; 
    $new_data['UserProfileName']['user_profile_id']=$userProfileId; 
    $this->UserProfileName->create(); 
    $this->UserProfileName->set($new_data); 
}  
$this->UserProfileContact->set($this->data); 
if ($this->UserProfileName->validates() && $this->UserProfileContact->validates()) { 
} else { 
    $errors = $this->UserProfileName->validationErrors; 
    $errors = $this->UserProfileContact->validationErrors; 
    pr($this->UserProfile->validationErrors); 
    pr($errors); 
} 

Форма ввода $ this-> данные:

Array 
(
    [UserProfile] => Array 
     (
      [id] => 1 
      [expiry_date] => 2017-06-30 
      [is_remarriage] => 0 
      [is_featured] => 1 
      [featured_date] => 2015-06-30 
      [featured_expity_date] => 2015-07-15 
      [language_id] => 1 
      [name] => Profile1 
      [gender_id] => 1 
      [date_of_birth] => 1988-06-30 
      [time_of_birth] => Array 
       (
        [hour] => 05 
        [min] => 11 
        [meridian] => pm 
       ) 

      [place_of_birth] => Trichy 
      [religion_id] => 1 
      [caste_id] => 3 
      [sub_caste_id] => 2 
      [community_id] => 3 
      [gothram_id] => 3 
      [star_id] => 5 
      [rasi_id] => 5 
      [food_habbit_id] => 2 
      [height] => 145 
      [height_type_id] => 1 
      [weight] => 50 
      [complexion_id] => 2 
      [blood_group_id] => 7 
      [disability_id] => 
      [other_disability] => 
      [talents] => Singing 
      [hobbies] => Handicrafts 
      [languages_konwn] => Tamil, English,Hindi 
      [qualification_id] => 1 
      [other_qualification] => 
      [employment_type_id] => 5 
      [job_details] => 
      [income] => 
      [income_type_id] => 1 
      [parents_alive_type_id] => 2 
      [father_name] => Fname 
      [father_job] => Business 
      [mother_name] => Mname 
      [mother_job] => house wife 
      [mother_caste_id] => 3 
      [brothers_elder] => 2 
      [brothers_younger] => 
      [brothers_married] => 1 
      [sisters_elder] => 
      [sisters_younger] => 
      [sisters_married] => 
      [family_status_id] => 2 
      [marital_status_id] => 
      [date_of_marriage] => 
      [date_of_divorce] => 
      [lived_together_duration] => 
      [cilidrean_details] => 
      [other_info] => 
      [is_show_photo] => 1 
     ) 

    [UserProfileName] => Array 
     (
      [0] => Array 
       (
        [id] => 1 
        [profile_id] => Profile1001 
       ) 

      [new] => Array 
       (
        [new_profile_id] => 
       ) 

     ) 

    [PropertyType] => Array 
     (
      [PropertyType] => Array 
       (
        [0] => 1 
        [1] => 4 
       ) 

     ) 

    [UserProfileExpectation] => Array 
     (
      [id] => 1 
      [qualification_id] => 2 
      [job_requirement_type_id] => 1 
      [preferred_place_of_job] => With in Tamil nadu 
      [min_income] => 900000/ann 
      [caste_id] => 3 
      [sub_caste_id] => 1 
      [community_id] => 1 
      [food_habbit_id] => 2 
      [marital_status_id] => 1 
      [is_horoscope_matching_required] => 1 
      [is_accept_disablity] => 0 
      [other_expectation] => 
     ) 

    [UserProfileHoroscopeDetail] => Array 
     (
      [id] => 1 
      [balance_dasa_name] => sun 
      [balance_dasa_years] => 12 
      [balance_dasa_months] => 9 
      [balance_dasa_days] => 25 
      [rasi_1] => sss 
      [rasi_2] => hggf 
      [rasi_3] => ffgd 
      [rasi_4] => 
      [rasi_12] => 
      [rasi_5] => 
      [rasi_11] => 
      [rasi_6] => dfgd 
      [rasi_10] => 
      [rasi_9] => fgdfd 
ghg 
fgf 
      [rasi_8] => 
      [rasi_7] => 
      [amsam_1] => 
      [amsam_2] => fg 
      [amsam_3] => 
      [amsam_4] => 
      [amsam_12] => fghfg 
      [amsam_5] => fghfg 
      [amsam_11] => fgf 
      [amsam_6] => 
      [amsam_10] => 
      [amsam_9] => 
      [amsam_8] => fghf 
      [amsam_7] => 
     ) 

    [UserProfileContact] => Array 
     (
      [email] => [email protected] 
      [permanent_address] => fhgfhg 
      [permanent_country_id] => 1 
      [permanent_zone_id] => 1 
      [permanent_city_id] => 1 
      [local_address] => 
      [local_country_id] => 1 
      [local_zone_id] => 1 
      [local_city_id] => 1 
      [phone_1] => 2134657898 
      [phone_2] => 
      [phone_3] => 
      [phone_4] => 
     ) 

    [images] => Array 
     (
      [1] => Array 
       (
        [name] => 
        [type] => 
        [tmp_name] => 
        [error] => 4 
        [size] => 0 
       ) 

      [2] => Array 
       (
        [name] => 
        [type] => 
        [tmp_name] => 
        [error] => 4 
        [size] => 0 
       ) 

      [3] => Array 
       (
        [name] => 
        [type] => 
        [tmp_name] => 
        [error] => 4 
        [size] => 0 
       ) 

     ) 

)` 

Он всегда идет к еще части, но когда я печатаю массив ошибок он пуст.

+0

Что означает «получение неудачи»? Не могли бы вы добавить дополнительную информацию о «сбое» ?. Вы также должны опубликовать соответствующую часть своего кода, чтобы лучше понять возможную ошибку. –

ответ

0

Я решил проблему путем изменения правила проверки

в правиле проверки я использовал 'required' => 'create',

и изменено на

'on' => 'create',

сейчас его работы.

0

Попробуйте это и измените в соответствии с вашими требованиями.

if(!empty($this->data)) 
{ 

    $this->User->set($this->data['User']); 
    $this->Contractor->set($this->data['Contractor']); 
    if ($this->User->validates() && $this->Contractor->validates()) 
    { 
     $this->data['User']['passwd'] = $this->Auth->password($this->data['User']['new_passwd']); 
     $this->data['User']['created'] = date("Y-m-d H:i:s"); 
     $user = $this->data['User']; 
     $contractor = $this->data['Contractor']; 
     //pr($this->data);die; 
     if($this->User->save($user)) 
     { 
      $newId = $this->User->getLastInsertId(); 
      $contractor['user_id'] = $newId; 
      if($this->Contractor->save($contractor)) 
      { 
        $this->redirect('/contractors/index') ;     
      } 
     } 
    }else{ 
     $this->validateErrors($this->User); 
     $this->validateErrors($this->Contractor); 
     $this->render(); 
    } 
} 
+0

Я попытался добавить параметр 'set' также' $ this-> UserProfileName-> set ($ this-> data ['UserProfileName']); $ this-> UserProfileName-> set ($ this-> data ['UserProfileContact']); ' –

Смежные вопросы