Skip to content

Commit

Permalink
Exclude value attribute from generated file inputs.
Browse files Browse the repository at this point in the history
Having a value attribute present causes HTML validation errors in HTML5
doctypes. It has no effect in other doctypes, and excluding it is always
valid.

Fixes #3440
  • Loading branch information
markstory committed Dec 9, 2012
1 parent 8a77a31 commit 2a8ebce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6018,6 +6018,10 @@ public function testFileUploadField() {
'/div'
);
$this->assertTags($result, $expected);

$this->Form->request->data['Model']['upload'] = 'no data should be set in value';
$result = $this->Form->file('Model.upload');
$this->assertTags($result, array('input' => array('type' => 'file', 'name' => 'data[Model][upload]', 'id' => 'ModelUpload')));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/View/Helper/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,8 @@ public function file($fieldName, $options = array()) {
$this->_secure($secure, array_merge($field, array($suffix)));
}

return $this->Html->useTag('file', $options['name'], array_diff_key($options, array('name' => '')));
$exclude = array('name' => '', 'value' => '');
return $this->Html->useTag('file', $options['name'], array_diff_key($options, $exclude));
}

/**
Expand Down

0 comments on commit 2a8ebce

Please sign in to comment.