mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing Helper::value() and extraction of habtm data. Refs #256
This commit is contained in:
parent
b974127562
commit
380b49a446
2 changed files with 13 additions and 5 deletions
|
@ -544,7 +544,7 @@ class Helper extends Overloadable {
|
||||||
$errors = $this->validationErrors;
|
$errors = $this->validationErrors;
|
||||||
$entity = $view->entity();
|
$entity = $view->entity();
|
||||||
if (!empty($entity)) {
|
if (!empty($entity)) {
|
||||||
return Set::extract($errors,join('.',$entity));
|
return Set::extract($errors, join('.', $entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,10 +645,18 @@ class Helper extends Overloadable {
|
||||||
|
|
||||||
$view =& ClassRegistry::getObject('view');
|
$view =& ClassRegistry::getObject('view');
|
||||||
$result = null;
|
$result = null;
|
||||||
|
|
||||||
$entity = $view->entity();
|
$entity = $view->entity();
|
||||||
if (!empty($this->data) && !empty($entity)) {
|
if (!empty($this->data) && !empty($entity)) {
|
||||||
$result = Set::extract($this->data,join('.',$entity));
|
$result = Set::extract($this->data, join('.', $entity));
|
||||||
|
}
|
||||||
|
|
||||||
|
$habtmKey = $this->field();
|
||||||
|
if (empty($result) && isset($this->data[$habtmKey]) && is_array($this->data[$habtmKey])) {
|
||||||
|
if (ClassRegistry::isKeySet($habtmKey)) {
|
||||||
|
$model =& ClassRegistry::getObject($habtmKey);
|
||||||
|
$result = $this->__selectedArray($this->data[$habtmKey], $model->primaryKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($result)) {
|
if (is_array($result)) {
|
||||||
|
|
|
@ -538,11 +538,11 @@ class HelperTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testMulitDimensionValue() {
|
function testMulitDimensionValue() {
|
||||||
$this->Helper->data = array();
|
$this->Helper->data = array();
|
||||||
for($i = 0; $i < 2; $i++) {
|
for ($i = 0; $i < 2; $i++) {
|
||||||
$this->Helper->data['Model'][$i] = 'what';
|
$this->Helper->data['Model'][$i] = 'what';
|
||||||
$result[] = $this->Helper->value("Model.{$i}");
|
$result[] = $this->Helper->value("Model.{$i}");
|
||||||
$this->Helper->data['Model'][$i] = array();
|
$this->Helper->data['Model'][$i] = array();
|
||||||
for($j = 0; $j < 2; $j++) {
|
for ($j = 0; $j < 2; $j++) {
|
||||||
$this->Helper->data['Model'][$i][$j] = 'how';
|
$this->Helper->data['Model'][$i][$j] = 'how';
|
||||||
$result[] = $this->Helper->value("Model.{$i}.{$j}");
|
$result[] = $this->Helper->value("Model.{$i}.{$j}");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue