Exclude value attribute from generated file inputs.

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
This commit is contained in:
mark_story 2012-12-09 13:31:01 -05:00
parent 8a77a31620
commit 2a8ebcea60
2 changed files with 6 additions and 1 deletions

View file

@ -6018,6 +6018,10 @@ class FormHelperTest extends CakeTestCase {
'/div' '/div'
); );
$this->assertTags($result, $expected); $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')));
} }
/** /**

View file

@ -1531,7 +1531,8 @@ class FormHelper extends AppHelper {
$this->_secure($secure, array_merge($field, array($suffix))); $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));
} }
/** /**