Skip to content

Commit

Permalink
Added binary type to field type map, defaulting to file input field
Browse files Browse the repository at this point in the history
Refs  #2071
  • Loading branch information
ravage84 committed Oct 15, 2013
1 parent 5a394c3 commit bf8a13a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -807,6 +807,36 @@ public function testTextFieldTypeNumberGenerationForIntegers() {
$this->assertTags($result, $expected);
}

/**
* Tests correct generation of file upload fields for binary fields
*
* @return void
*/
public function testFileUploadFieldTypeGenerationForBinaries() {
$model = ClassRegistry::getObject('Contact');
$model->setSchema(array('foo' => array(
'type' => 'binary',
'null' => false,
'default' => null,
'length' => 1024
)));

$this->Form->create('Contact');
$result = $this->Form->input('foo');
$expected = array(
'div' => array('class' => 'input file'),
'label' => array('for' => 'ContactFoo'),
'Foo',
'/label',
array('input' => array(
'type' => 'file', 'name' => 'data[Contact][foo]',
'id' => 'ContactFoo'
)),
'/div'
);
$this->assertTags($result, $expected);
}

/**
* testFormSecurityMultipleFields method
*
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -1147,7 +1147,8 @@ protected function _magicOptions($options) {
'boolean' => 'checkbox', 'timestamp' => 'datetime',
'text' => 'textarea', 'time' => 'time',
'date' => 'date', 'float' => 'number',
'integer' => 'number', 'decimal' => 'number'
'integer' => 'number', 'decimal' => 'number',
'binary' => 'file'
);

if (isset($this->map[$type])) {
Expand Down

0 comments on commit bf8a13a

Please sign in to comment.