mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Merge pull request #2139 from ravage84/file-inputs-for-binary-fields
Added binary type to field type map, defaulting to file input field
This commit is contained in:
commit
839aecbad6
2 changed files with 32 additions and 1 deletions
|
@ -807,6 +807,36 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertTags($result, $expected);
|
$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
|
* testFormSecurityMultipleFields method
|
||||||
*
|
*
|
||||||
|
|
|
@ -1147,7 +1147,8 @@ class FormHelper extends AppHelper {
|
||||||
'boolean' => 'checkbox', 'timestamp' => 'datetime',
|
'boolean' => 'checkbox', 'timestamp' => 'datetime',
|
||||||
'text' => 'textarea', 'time' => 'time',
|
'text' => 'textarea', 'time' => 'time',
|
||||||
'date' => 'date', 'float' => 'number',
|
'date' => 'date', 'float' => 'number',
|
||||||
'integer' => 'number', 'decimal' => 'number'
|
'integer' => 'number', 'decimal' => 'number',
|
||||||
|
'binary' => 'file'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isset($this->map[$type])) {
|
if (isset($this->map[$type])) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue