mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing '2.name' style fields when creating multiple record forms.
This commit is contained in:
parent
96cc1b98b4
commit
25870441bc
2 changed files with 26 additions and 9 deletions
|
@ -276,6 +276,11 @@ class HelperTest extends CakeTestCase {
|
||||||
$expected = array('HelperTestPost', 'body');
|
$expected = array('HelperTestPost', 'body');
|
||||||
$this->assertEquals($expected, $this->View->entity());
|
$this->assertEquals($expected, $this->View->entity());
|
||||||
|
|
||||||
|
|
||||||
|
$this->Helper->setEntity('2.body');
|
||||||
|
$expected = array('HelperTestPost', '2', 'body');
|
||||||
|
$this->assertEquals($expected, $this->View->entity());
|
||||||
|
|
||||||
$this->Helper->setEntity('Something.else');
|
$this->Helper->setEntity('Something.else');
|
||||||
$expected = array('Something', 'else');
|
$expected = array('Something', 'else');
|
||||||
$this->assertEquals($expected, $this->View->entity());
|
$this->assertEquals($expected, $this->View->entity());
|
||||||
|
@ -548,10 +553,12 @@ class HelperTest extends CakeTestCase {
|
||||||
$expected = array('HelperTestPost');
|
$expected = array('HelperTestPost');
|
||||||
$this->assertEquals($expected, $this->View->entity());
|
$this->assertEquals($expected, $this->View->entity());
|
||||||
|
|
||||||
$this->Helper->setEntity('date.month');
|
foreach (array('year', 'month', 'day', 'hour', 'minute', 'meridian') as $d) {
|
||||||
$expected = array('HelperTestPost', 'date', 'month');
|
$this->Helper->setEntity('date.' . $d);
|
||||||
|
$expected = array('HelperTestPost', 'date', $d);
|
||||||
$this->assertEquals($expected, $this->View->entity());
|
$this->assertEquals($expected, $this->View->entity());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testMulitDimensionValue method
|
* testMulitDimensionValue method
|
||||||
|
|
|
@ -416,6 +416,13 @@ class Helper extends Object {
|
||||||
) {
|
) {
|
||||||
$entity = $view->modelScope . '.' . $entity;
|
$entity = $view->modelScope . '.' . $entity;
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
$count === 2 &&
|
||||||
|
is_numeric($parts[0]) &&
|
||||||
|
!is_numeric($parts[1])
|
||||||
|
) {
|
||||||
|
$entity = $view->modelScope . '.' . $entity;
|
||||||
|
}
|
||||||
$view->entityPath = $entity;
|
$view->entityPath = $entity;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -567,11 +574,8 @@ class Helper extends Object {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function model() {
|
public function model() {
|
||||||
if (!empty($this->_View->association)) {
|
$entity = $this->_View->entity();
|
||||||
return $this->_View->association;
|
return isset($entity[0]) ? $entity[0] : null;
|
||||||
} else {
|
|
||||||
return $this->_View->model;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -589,7 +593,13 @@ class Helper extends Object {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function field() {
|
public function field() {
|
||||||
return $this->_View->field;
|
$entity = $this->_View->entity();
|
||||||
|
$count = count($entity);
|
||||||
|
$last = $entity[$count - 1];
|
||||||
|
if (in_array($last, $this->_fieldSuffixes)) {
|
||||||
|
$last = isset($entity[$count - 2]) ? $entity[$count - 2] : null;
|
||||||
|
}
|
||||||
|
return $last;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue