Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Very basic FormHelper::create() test is passing again.

FormHelper doesn't need to add ID's to every element it creates.
Removing id generation on form elements reduces the chances it will
create duplicate ID's requiring developer intervention.
  • Loading branch information...
commit 516b7bb1e514cdfd7ee33ccece4484fe507e2107 1 parent 11014f9
@markstory markstory authored
View
7 src/View/Helper/FormHelper.php
@@ -159,7 +159,7 @@ class FormHelper extends Helper {
* @var array
*/
protected $_defaultTemplates = [
- 'formstart' => '<form {{attrs}}>',
+ 'formstart' => '<form{{attrs}}>',
'formend' => '</form>',
];
@@ -297,11 +297,6 @@ public function create($model = null, $options = []) {
'encoding' => strtolower(Configure::read('App.encoding')),
], $options);
- if (!isset($options['id'])) {
- $domId = isset($options['action']) ? $options['action'] : $this->request['action'];
- $options['id'] = $this->domId($domId . 'Form');
- }
-
if ($options['action'] === null && $options['url'] === null) {
$options['action'] = $this->request->here(false);
} elseif (empty($options['url']) || is_array($options['url'])) {
View
6 tests/TestCase/View/Helper/FormHelperTest.php
@@ -605,16 +605,14 @@ public function testCreateContextSelectionBuiltIn($data, $class) {
* @return void
*/
public function testCreateWithSecurity() {
- $this->markTestIncomplete();
$this->Form->request->params['_csrfToken'] = 'testKey';
$encoding = strtolower(Configure::read('App.encoding'));
$article = new Article();
$result = $this->Form->create($article, [
'url' => '/contacts/add',
- 'context' => ['table' => 'Articles']
]);
$expected = array(
- 'form' => array('method' => 'post', 'action' => '/contacts/add', 'accept-charset' => $encoding, 'id' => 'ContactAddForm'),
+ 'form' => array('method' => 'post', 'action' => '/contacts/add', 'accept-charset' => $encoding),
'div' => array('style' => 'display:none;'),
array('input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST')),
array('input' => array(
@@ -624,7 +622,7 @@ public function testCreateWithSecurity() {
);
$this->assertTags($result, $expected);
- $result = $this->Form->create('Contact', array('url' => '/contacts/add', 'id' => 'MyForm'));
+ $result = $this->Form->create($article, ['url' => '/contacts/add', 'id' => 'MyForm']);
$expected['form']['id'] = 'MyForm';
$this->assertTags($result, $expected);
}
Please sign in to comment.
Something went wrong with that request. Please try again.