Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added binary type to field type map, defaulting to file input field

Refs  #2071
  • Loading branch information...
commit bf8a13a77c76f96f36686ba9d020f4ec291afa36 1 parent 5a394c3
Marc Würth ravage84 authored
30 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
View
@@ -808,6 +808,36 @@ public function testTextFieldTypeNumberGenerationForIntegers() {
}
/**
+ * 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
*
* Test secure() with multiple row form. Ensure hash is correct.
3  lib/Cake/View/Helper/FormHelper.php
View
@@ -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])) {
Please sign in to comment.
Something went wrong with that request. Please try again.