mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Enabling suffixes for virtual fields, fixes #3724
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6449 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
7248048d85
commit
7f673226d7
2 changed files with 17 additions and 2 deletions
|
@ -328,8 +328,8 @@ class Helper extends Overloadable {
|
||||||
|
|
||||||
$sameScope = $hasField = false;
|
$sameScope = $hasField = false;
|
||||||
$parts = preg_split('/\/|\./', $entity);
|
$parts = preg_split('/\/|\./', $entity);
|
||||||
|
|
||||||
$model = $view->model;
|
$model = $view->model;
|
||||||
|
|
||||||
if(count($parts) === 1 || is_numeric($parts[0])) {
|
if(count($parts) === 1 || is_numeric($parts[0])) {
|
||||||
$sameScope = true;
|
$sameScope = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -350,11 +350,15 @@ class Helper extends Overloadable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($sameScope === true && in_array($parts[0], array_keys($ModelObj->hasAndBelongsToMany))) {
|
if ($sameScope === true && in_array($parts[0], array_keys($ModelObj->hasAndBelongsToMany))) {
|
||||||
$sameScope = false;
|
$sameScope = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($parts[0] == $view->field && $view->field != $view->model) {
|
||||||
|
array_unshift($parts, $model);
|
||||||
|
$hasField = true;
|
||||||
|
}
|
||||||
$view->field = $view->modelId = $view->fieldSuffix = $view->association = null;
|
$view->field = $view->modelId = $view->fieldSuffix = $view->association = null;
|
||||||
|
|
||||||
switch (count($parts)) {
|
switch (count($parts)) {
|
||||||
|
|
|
@ -1019,6 +1019,17 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->Form->data['Model']['field'] = '2008-01-01 00:00:00';
|
$this->Form->data['Model']['field'] = '2008-01-01 00:00:00';
|
||||||
$result = $this->Form->dateTime('Model.field', 'DMY', '12', null, array(), false);
|
$result = $this->Form->dateTime('Model.field', 'DMY', '12', null, array(), false);
|
||||||
$this->assertPattern('/option value="12" selected="selected"/', $result);
|
$this->assertPattern('/option value="12" selected="selected"/', $result);
|
||||||
|
|
||||||
|
$this->Form->create('Contact');
|
||||||
|
$result = $this->Form->input('published');
|
||||||
|
$this->assertPattern('/name="data\[Contact\]\[published\]\[month\]"/', $result);
|
||||||
|
$this->assertPattern('/name="data\[Contact\]\[published\]\[day\]"/', $result);
|
||||||
|
$this->assertPattern('/name="data\[Contact\]\[published\]\[year\]"/', $result);
|
||||||
|
|
||||||
|
$result = $this->Form->input('published2', array('type' => 'date'));
|
||||||
|
$this->assertPattern('/name="data\[Contact\]\[published2\]\[month\]"/', $result);
|
||||||
|
$this->assertPattern('/name="data\[Contact\]\[published2\]\[day\]"/', $result);
|
||||||
|
$this->assertPattern('/name="data\[Contact\]\[published2\]\[year\]"/', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testMonth() {
|
function testMonth() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue