What I have done is
$strippedCertifications = $this->data;
$strippedCertifications = Set::extract($this->data,
'Certification.Certification.Certification.{n}');
$arr = array('Certification' => array ('Certification' =>
$strippedCertifications));
$this->$strippedCertifications->set($arr);
if ($this->Certification->validates()) {
return true;
}
return false;
So I get the values from the array only then rebuild the array I need it and
it validates now.
But is there a cleaner way to do this based on the code above?
-----Original Message-----
From: Dave Maharaj :: WidePixels.com [mailto:[email protected]]
Sent: June-11-09 1:32 PM
To: [email protected]
Subject: Extract help
I am using the Wizard component and validating HABTM but the Wizard spits
out an array like this:
debug($this->data);
[Certification] => Array
(
[Certification] => Array
(
[Certification] => Array
(
[0] => sdgsdfg
)
)
)
This will not validate for some reason...i think because of the triple
[Certification] My validation compares submitted values against possible
values in the db with
function checkValues($data)
{
if (!empty($this->data)) {
$results =
array_diff($this->data['Certification']['Certification'],
$this->find('list', array('fields' => 'id', 'order' => 'id ASC')));
if (empty($results)) {
return true;
} else {
return false;
}
}
}
So my question is how can I strip out the extra [Certification] to maye the
array look like
[Certification] => Array
(
[Certification] => Array
(
[0] => sdgsdfg
)
)
Then pass it to the model for validation?
Thanks
Dave
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---