How to fetch array value from new:CActiveRecord:private - php

i have the following array
Ticket Object ( [_new:CActiveRecord:private] => [_attributes:CActiveRecord:private] => Array ( [TicketId] => 00002 [TicketTitle] => testone [TicketOwner] => 70 [ClientCompanyName] => Hidden Oasis [ClientFirstName] => Brenda & David [ClientLastName] => Kilby [ClientAdminEmail] => manager#hiddenoasisrv.com [ClientPhone] => (928)765-2341 [SupportLevel] => bronze [SupportIssue] => Application error [HoursPurchased] => 2 [HoursBalanceAvailable] => 2 [TicketReviewedBy] => rezsys [TicketStatus] => Open [TicketStartDate] => 2009-08-29 21:25:00 [TicketClosedDate] => 2009-08-29 21:25:00 [TicketLastModified] => 2009-08-29 21:25:00 [TimeOfPhoneSupport] => AM ) [_related:CActiveRecord:private] => Array ( ) [_c:CActiveRecord:private] => [_pk:CActiveRecord:private] => 00002 [_alias:CActiveRecord:private] => t [_errors:CModel:private] => Array ( ) [_validators:CModel:private] => [_scenario:CModel:private] => update [_e:CComponent:private] => [_m:CComponent:private] => )
How to fetch "TicketTitle" from the above array?
$Criteria = new CDbCriteria();
$open = Ticket::model()->findByAttributes(array('TicketStatus'=>$status));
print_r($open);

Related

Php check and replace if value exist in multi array?

Problem:
I dont know/understand how to check if date and place exists on the same "row" and they exists more then once.
Second, how do i then merge an array
my case MergeArray with ArraySchedule
Code:
$ArraySchedule = array();
while ($data = $stmt -> fetch(PDO::FETCH_ASSOC)) {
$schedules = array(
"id" => $data['id'],
"name" => $data['name'],
"date" => $data['date'],
"time" => $data['time'],
"place_id" => $data['place_id'],
"place" => $data['place'],
);
array_push($ArraySchedule, $schedules);
}
$dupe_array = array();
foreach ($ArraySchedule as $key => $value) {
if(++$dupe_array[$value["date"]] > 1 && ++$dupe_array[$value["place_id"]] > 1 ){
// this statement is wrong, i want something like:
// if date and place_id exists on the same "row" and they exists more then once
}
}
What i want to do:
Check if ArraySchedule contains schedules that have the same date and place,
if there is more than one schedule that has the same date and place_id.
then I want to update ArraySchedule with this structure
$MergeArray = array(
"id" => ArraySchedule['id'],
"name" => array(
"name" => scheduleSameDateAndPlace['name'],
"name" => scheduleSameDateAndPlace['name'],
"name" => scheduleSameDateAndPlace['name'],
),
"date" => $ArraySchedule['date'],
"time" => $ArraySchedule['time'],
"place_id" => $ArraySchedule['place_id'],
"place_name" => $ArraySchedule['place_name'],
),
MergeArray with ArraySchedule?
anyway...
Output I think I want?
Print_r($ArraySchedule)
array(
[0] =>
array(
[id] => 1
[names] => Simon
[date] => 2019-01-02
[time] 18.00
[place_id] => Tystberga Park
[place] => Tystberga
)
[1] =>
array(
[id] => 2
//[names] insted of [name]?
[names] =>
array(
[name] => Vincent
[name] => Angel
[name] => Kim
)
[date] => 2019-02-17
[time] => 13.00
[place_id] => Borås Park
[place] => Borås
)
[2] =>
array(
[id] => 3
// [names] is always an array?
[names] => Caitlyn
[date] => 2019-03-15
[time] 13.00
[place_id] => Plaza Park
[place] => EvPark
)
)
You can use array-reduce. Consider the following:
function mergeByDateAndPlace($carry, $item) {
$key = $item["place_id"] . $item["date"]; // creating key matching exact place and date
if (!isset($carry[$key])) {
$carry[$key]["name"] = $item["name"];
} else {
$carry[$key] = $item;
$item["name"] = [$item["name"]]; // make default array with 1 element so later can be append other names
}
return $carry;
}
Now use it with:
$MergeArray = array_reduce($ArraySchedule, "mergeByDateAndPlace", []);
If you later want to know if there were any duplicate you can just loop on $MergeArray. You can also use array_values if you want to discard the concat keys.
Notice #Nick 2 important comment about saving the first loop and the "time" value that need to be decided. Also notice your desire output contain multi element with the same key ("name") - you need to append them with int key - Array can not have duplicate keys.
Hope that helps!
Here is my data from my database:
var_export($ArraySchedule)
array (
0 => array ( 'id' => '225', 'place_id' => 'Alviks Kulturhus', 'name' => 'BarraBazz', 'date' => '2019-03-19', 'placeadress' => 'Gustavslundsvägen 1', ),
1 => array ( 'id' => '229', 'place_id' => 'Axelhuset Göteborg', 'name' => 'Anders Björk', 'date' => '2019-04-08', 'placeadress' => 'Axel Dahlströms torg 3', ),
2 => array ( 'id' => '230', 'place_id' => 'Axelhuset Göteborg', 'name' => 'Black Jack', 'date' => '2019-04-08', 'placeadress' => 'Axel Dahlströms torg 3', ),
3 => array ( 'id' => '227', 'place_id' => 'Arosdansen Syrianska Kulturcentret', 'name' => 'BarraBazz', 'date' => '2019-05-08', 'placeadress' => 'Narvavägen 90', ),
4 => array ( 'id' => '228', 'place_id' => 'Aspåsnäset', 'name' => 'Blender', 'date' => '2019-05-25', 'placeadress' => 'Aspåsnäset 167', ),
5 => array ( 'id' => '226', 'place_id' => 'Arenan Västervik Resort', 'name' => 'Blender', 'date' => '2019-06-29', 'placeadress' => 'Lysingsvägen', ),
6 => array ( 'id' => '222', 'place_id' => 'Alingsåsparken', 'name' => 'Bendéns', 'date' => '2019-07-16', 'placeadress' => 'Folkparksgatan 3A', ),
7 => array ( 'id' => '223', 'place_id' => 'Alingsåsparken', 'name' => 'Charlies', 'date' => '2019-07-16', 'placeadress' => 'Folkparksgatan 3A', ),
8 => array ( 'id' => '224', 'place_id' => 'Allhuset Södertälje', 'name' => 'Cedrix', 'date' => '2019-07-16', 'placeadress' => 'Barrtorpsvägen 1A', ), )
I want to update the "name" with an array of names everytime that place_id and date are the same.
This is the output I want:
Array (
[0] =>
Array ( [id] => 225 [place_id] => Alviks Kulturhus [name] => BarraBazz [date] => 2019-03-19 [placeadress] => Gustavslundsvägen 1 )
[1] =>
Array ( [id] => 229 [place_id] => Axelhuset Göteborg [name] => Array([0] => Anders Björk [1] => Black Jack ) [date] => 2019-04-08 [placeadress] => Axel Dahlströms torg 3 )
[3] =>
Array ( [id] => 227 [place_id] => Arosdansen Syrianska Kulturcentret [name] => BarraBazz [date] => 2019-05-08 [placeadress] => Narvavägen 90 )
[4] =>
Array ( [id] => 228 [place_id] => Aspåsnäset [name] => Blender [date] => 2019-05-25 [placeadress] => Aspåsnäset 167 )
[5] =>
Array ( [id] => 226 [place_id] => Arenan Västervik Resort [name] => Blender [date] => 2019-06-29 [placeadress] => Lysingsvägen )
[6] =>
Array ( [id] => 222 [place_id] => [Alingsåsparken] [name] => Array([0] => Bendéns [1] => Charlies) [date] => 2019-07-16 [placeadress] => Folkparksgatan 3A )
[8] =>
Array ( [id] => 224 [place_id] => Allhuset Södertälje [name] => Cedrix [date] => 2019-07-16 [placeadress] => Barrtorpsvägen 1A ) )
Here is my updated code
$sql = "SELECT `schedule`.`id`,`schedule`.`place_id`,`schedule`.`name`,`schedule`.`date`,`places`.`placeadress` FROM `schedule` INNER JOIN `places` ON `schedule`.`place_id`=`places`.`place_id` ORDER BY `date`";
$stmt = $db -> prepare($sql);
$stmt -> execute();
$ArraySchedule = $stmt->fetchAll(PDO::FETCH_ASSOC);
var_export($ArraySchedule);
$DatePlace = array();
foreach ($ArraySchedule as $key => $Schedule){
$Arrayquery = "SELECT `schedule`.`id`,`schedule`.`place_id`,`schedule`.`name`,`schedule`.`date`,`places`.`placeadress` FROM `schedule` INNER JOIN `places` ON `schedule`.`place_id`=`places`.`place_id` WHERE `schedule`.`date`= :date_ AND `schedule`.`place_id` = :place_id ORDER BY `date`";
$ArrayStmt = $db->prepare($Arrayquery);
$ArrayStmt -> execute(array(":date_" => $Schedule['date'],":place_id" => $Schedule['place_id']));
//Getting every $Schedule that has the same date and place_id
if($ArrayStmt->rowCount() > 1){
//Here i want two update the name inside
//$ArrayArraySchedule with an array of names
//that has the same place and date?
}
}
print_r($ArraySchedule);

How to get the highest and lowest Values and sum from Multidimensional array in PHP

I have tried using this example here Return index of highest value in an array
But that does not go into a multi dimensional Array
I have tried ARRAY_COLUMN(), array_values(), array_shift, Max and Min but they are not getting the info i need
I want to be able to loop thru and get to:
[pricing]
then Check pricing to see which is the highest and lowest in the nested array
so like below which total was the Highest and lowest trades on these dates
[2017-09-22]
[2017-09-23]
obviously [2017-09-23] is a simple one, i just dint want to add much more code for ppl helping to go thru.
The Array i create looks like this:
Array
(
[2017-09-23] => Array
(
[0] => Array
(
[timestamp] => 1506169387000
[pricing] => 9.5470
[qty] => 25
[total] => 238.675
[date] => 2017-09-23
)
)
[2017-09-22] => Array
(
[0] => Array
(
[timestamp] => 1506093083000
[pricing] => 9.6300
[qty] => 25
[total] => 240.75
[date] => 2017-09-22
)
[1] => Array
(
[timestamp] => 1506077220000
[pricing] => 8.7190
[qty] => 13
[total] => 113.347
[date] => 2017-09-22
)
[2] => Array
(
[timestamp] => 1506077109000
[pricing] => 8.6800
[qty] => 83
[total] => 720.44
[date] => 2017-09-22
)
[3] => Array
(
[timestamp] => 1506065258000
[pricing] => 8.7100
[qty] => 25
[total] => 217.75
[date] => 2017-09-22
)
)
in the example above i would like it to Create a new array with only the following
date -> last timestamp -> Highest pricing -> Lowest lowest -> Total of all Totals -> first Timestamp
EDIT: the last and first Timestamp are basically the first and last index so in this case:
[timestamp] => 1506093083000 and [timestamp] => 1506065258000
or Index [0] and index [3]
The array from your question:
$array = array (
'2017-09-23' =>
array (
0 =>
array (
'timestamp' => '1506169387000',
'pricing' => '9.5470',
'qty' => '25',
'total' => '238.675',
'date' => '2017-09-23',
),
),
'2017-09-22' =>
array (
0 =>
array (
'timestamp' => '1506093083000',
'pricing' => '9.6300',
'qty' => '25',
'total' => '240.75',
'date' => '2017-09-22',
),
1 =>
array (
'timestamp' => '1506077220000',
'pricing' => '8.7190',
'qty' => '13',
'total' => '113.347',
'date' => '2017-09-22',
),
2 =>
array (
'timestamp' => '1506077109000',
'pricing' => '8.6800',
'qty' => '83',
'total' => '720.44',
'date' => '2017-09-22',
),
3 =>
array (
'timestamp' => '1506065258000',
'pricing' => '8.7100',
'qty' => '25',
'total' => '217.75',
'date' => '2017-09-22',
),
),
);
To get the values maybe you can use array_map and with this the function array_column is the key of all, try with this:
$values = array_map(function($dates) {
$timestamps = array_column($dates, 'timestamp');
$pricings = array_column($dates, 'pricing');
return [
'max_pricing' => max($pricings),
'lowest_pricing' => min($pricings),
'total_of_totals' => array_sum(array_column($dates, 'total')),
'first_timestamp' => reset($timestamps),
'last_timestamp' => end($timestamps),
];
}, $array);
$values is an array with the filter values that you need:
Array
(
[2017-09-23] => Array
(
[max_pricing] => 9.5470
[lowest_pricing] => 9.5470
[total_of_totals] => 238.675
[first_timestamp] => 1506169387000
[last_timestamp] => 1506169387000
)
[2017-09-22] => Array
(
[max_pricing] => 9.6300
[lowest_pricing] => 8.6800
[total_of_totals] => 1292.287
[first_timestamp] => 1506093083000
[last_timestamp] => 1506065258000
)
)
EDIT
Get the pricing of the [first_timestamp] and [last_timestamp]
$values = array_map(function($dates) {
$timestamps = array_column($dates, 'timestamp');
$pricings = array_column($dates, 'pricing');
return [
'max_pricing' => max($pricings),
'lowest_pricing' => min($pricings),
'total_of_totals' => array_sum(array_column($dates, 'total')),
'first_timestamp' => [
'value' => reset($timestamps),
'pricing' => $pricings[each($timestamps)['key']]
],
'last_timestamp' => [
'value' => end($timestamps),
'pricing' => $pricings[each($timestamps)['key']]
]
];
}, $array);
I added an array to both timestamps with the value of these and the pricing.
Array
(
[2017-09-23] => Array
(
[max_pricing] => 9.5470
[lowest_pricing] => 9.5470
[total_of_totals] => 238.675
[first_timestamp] => Array
(
[value] => 1506169387000
[pricing] => 9.5470
)
[last_timestamp] => Array
(
[value] => 1506169387000
[pricing] => 9.5470
)
)
[2017-09-22] => Array
(
[max_pricing] => 9.6300
[lowest_pricing] => 8.6800
[total_of_totals] => 1292.287
[first_timestamp] => Array
(
[value] => 1506093083000
[pricing] => 9.6300
)
[last_timestamp] => Array
(
[value] => 1506065258000
[pricing] => 8.7100
)
)
)

How to achive below multi dimentional array in PHP?

<?php
[USED] => Array
(
[USER] => Array
(
[#attributes] => Array
(
[NAME] => locuz
[HOST] => srpth1cn03.local
[IP] => 10.106.2.48
[USED_LICENSES] => 1
[LOGIN_TIME] => 2014-12-10 07:34
[CHECKOUT_TIME] => 2014-12-10 07:34
)
)
)
I want to change above array to below:
[USED] => Array
(
[USER] => Array
(
[0] => Array
(
[#attributes] => Array
(
[NAME] => rdtank
[HOST] => it30992
[IP] => 10.106.21.134
[DENIED_LICENSES] => 1
[LOGIN_TIME] => 2014-12-09 15:55
[DENIAL_TIME] => 2014-12-09 15:55
)
)
)
)
Put a [] before you save attributes as below.
foreach($all_attributes as $attributes){
$sample_array['USED']['USER'][] = $attributes;
}
the code you wrote seems the result of 2 array dump.
so if you need to setup 2 variable in php that contains data you should use this code
<?php
$used = array(
'users' => array(
array(
'name' => 'locuz',
'host' => 'srpth1cn03.local',
'ip' => '10.106.2.48',
'used_licenses' => 1,
'login_time' => '2014-12-10 07:34',
'checkout_time' => '2014-12-10 07:34'
)
)
);
$denied = array(
'users' => array(
array(
'name' => 'rdtank',
'host' => 'it30992',
'ip' => '10.106.21.134',
'denied_licenses' => 1,
'login_time' => '2014-12-09 15:55',
'denial_time' => '2014-12-09 15:55'
)
)
);
hope this helps.

Extracting values from JSON in PHP

I am currently experimenting with the Discogs API, using PHP. My query against their API is returned as JSON, which I can decoding using:
$trackMeta = json_decode($trackMeta, true);
I'd then like to be able to access certain elements within the data that is returned. Using print_r($trackMeta);outputs the below data:
Array ( [pagination] => Array ( [per_page] => 1 [pages] => 7 [page] => 1 [urls] => Array ( [last] => http://api.discogs.com/database/search?artist=siren&q=snorkel&per_page=1&page=7 [next] => http://api.discogs.com/database/search?artist=siren&q=snorkel&per_page=1&page=2 ) [items] => 7 ) [results] => Array ( [0] => Array ( [style] => Array ( [0] => Drum n Bass ) [thumb] => http://api-img.discogs.com/cf1HxM29IXQKNsSdrwYioa0uEeI=/fit-in/150x150/filters:strip_icc():format(jpeg):mode_rgb()/discogs-images/R-3581480-1336678182-5777.jpeg.jpg [format] => Array ( [0] => Vinyl [1] => 12" [2] => 45 RPM ) [country] => UK [barcode] => Array ( ) [uri] => /Siren-21-Vicious-Circle-Snorkel-SPY-Remix-Solitude/master/433189 [community] => Array ( [want] => 66 [have] => 81 ) [label] => Array ( [0] => Siren Records ) [catno] => SIREN001 [year] => 2012 [genre] => Array ( [0] => Electronic ) [title] => Siren (21) / Vicious Circle (3) - Snorkel (S.P.Y. Remix) / Solitude [resource_url] => http://api.discogs.com/masters/433189 [type] => master [id] => 433189 ) ) )
When trying to use a foreach loop on $trackMeta, I can only return 171 which I believe relates to per_page pages and page.
How can I access data deeper in this array? For example values such as thumb or year or genre?
$trackMeta is an associative array:
$trackMeta = array (
'pagination' => array (
'per_page' => 1,
'pages' => 7,
'page' => 1,
'urls' => array (
'last' => 'http://api.discogs.com/database/search?artist=siren&q=snorkel&per_page=1&page=7',
'next' => 'http://api.discogs.com/database/search?artist=siren&q=snorkel&per_page=1&page=2'
),
'items' => 7
),
'results' => array (
0 => array (
'style' => array (
0 => 'Drum n Bass'
),
'thumb' => 'http://api-img.discogs.com/cf1HxM29IXQKNsSdrwYioa0uEeI=/fit-in/150x150/filters:strip_icc():format(jpeg):mode_rgb()/discogs-images/R-3581480-1336678182-5777.jpeg.jpg',
'format' => array (
0 => 'Vinyl',
1 => '12"',
2 => '45 RPM'
),
'country' => 'UK',
'barcode' => array ( ),
'uri' => '/Siren-21-Vicious-Circle-Snorkel-SPY-Remix-Solitude/master/433189',
'community' => array (
'want' => 66,
'have' => 81
),
'label' => array (
0 => 'Siren Records'
),
'catno' => 'SIREN001',
'year' => 2012,
'genre' => array (
0 => 'Electronic'
),
'title' => 'Siren (21) / Vicious Circle (3) - Snorkel (S.P.Y. Remix) / Solitude',
'resource_url' => 'http://api.discogs.com/masters/433189',
'type' => 'master',
'id' => 433189
)
)
);
For example, you can access thumb with the following code:
print_r($trackMeta['results'][0]['thumb']);

CakePHP - validation returning false

validates() getting failed, but the validationErrors is empty in CakePHP 2.x, even I have user unlockedActions for this method but still getting this error, while inserting its working fine. Only edit is not working.
This my controller code:
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);
}
The form input $this->data is:
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] => jayashree+profile25#jbcs.co.in
[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
)
)
)`
It always goes to else part, but when I print the error array it's empty.
Try this and modify according your requirement.
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();
}
}
I have solved the issue by change the validation rule
in validation rule i've used
'required' => 'create',
and changed to
'on' => 'create',
now its working.

Categories