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:
nate 2008-02-11 02:20:43 +00:00
parent 7248048d85
commit 7f673226d7
2 changed files with 17 additions and 2 deletions

View file

@ -328,8 +328,8 @@ class Helper extends Overloadable {
$sameScope = $hasField = false;
$parts = preg_split('/\/|\./', $entity);
$model = $view->model;
if(count($parts) === 1 || is_numeric($parts[0])) {
$sameScope = true;
} 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;
}
}
if ($parts[0] == $view->field && $view->field != $view->model) {
array_unshift($parts, $model);
$hasField = true;
}
$view->field = $view->modelId = $view->fieldSuffix = $view->association = null;
switch (count($parts)) {

View file

@ -1019,6 +1019,17 @@ class FormHelperTest extends CakeTestCase {
$this->Form->data['Model']['field'] = '2008-01-01 00:00:00';
$result = $this->Form->dateTime('Model.field', 'DMY', '12', null, array(), false);
$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() {