diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index a138629a5..6a0ef7ad8 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -140,7 +140,6 @@ class FormHelper extends AppHelper { $view->modelId = $id; $options = am(array( 'type' => ($created && empty($options['action'])) ? 'put' : 'post', - 'id' => $model . ife($created, 'Edit', 'Add') . 'Form', 'action' => null, 'url' => null, 'default' => true), @@ -652,9 +651,11 @@ class FormHelper extends AppHelper { break; } - if ($type != 'hidden' && $error !== false) { - $out .= $this->error($fieldName, $error); + if ($type != 'hidden') { $out .= $after; + if ($error !== false) { + $out .= $this->error($fieldName, $error); + } } if (isset($divOptions)) { $out = $this->Html->div($divOptions['class'], $out, $divOptions); @@ -1363,4 +1364,4 @@ class FormHelper extends AppHelper { return $this->__options[$name]; } } -?> +?> \ No newline at end of file diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index a520d4917..b2123b08e 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -45,6 +45,7 @@ class ContactTestController extends Controller { } class Contact extends Model { + var $primaryKey = 'id'; var $useTable = false; var $name = 'Contact'; @@ -193,8 +194,7 @@ class FormHelperTest extends CakeTestCase { $this->UserForm =& new UserForm(); $this->UserForm->OpenidUrl =& new OpenidUrl(); - $data = array('UserForm' => array('name' => 'user'), - 'OpenidUrl' => array('url' => 'http://www.cakephp.org')); + $data = array('UserForm' => array('name' => 'user'), 'OpenidUrl' => array('url' => 'http://www.cakephp.org')); $result = $this->UserForm->OpenidUrl->create($data); $this->assertTrue($result); @@ -301,6 +301,23 @@ class FormHelperTest extends CakeTestCase { $this->assertEqual($result, $expected); unset($this->Form->data); + + $this->Form->validationErrors['Model']['field'] = 'Badness!'; + $result = $this->Form->input('Model.field'); + $expected = '
'; + $this->assertPattern('/^