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);
}
的形式輸入$這個 - >數據是:
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
)
)
)`
它總是轉到其他部分,但是當我打印錯誤數組是空的。
這意味着什麼「失敗」?你能否添加更多關於「失敗」的信息?您還應該發佈代碼的相關部分,以便更好地理解可能的錯誤。 –