Skip to content

Commit

Permalink
adding test case
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Oct 23, 2012
1 parent 9a9ac6f commit 5064601
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
23 changes: 23 additions & 0 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -2650,6 +2650,29 @@ public function testInputWithMatchingFieldAndModelName() {
'/div'
);
$this->assertTags($result, $expected);

$this->View->viewVars['balances'] = array(0 => 'nothing', 1 => 'some', 100 => 'a lot');
$this->Form->request->data = array('ValidateUser' => array('balance' => 1));
$result = $this->Form->input('ValidateUser.balance');
$expected = array(
'div' => array('class' => 'input select'),
'label' => array('for' => 'ValidateUserBalance'),
'Balance',
'/label',
'select' => array('name' => 'data[ValidateUser][balance]', 'id' => 'ValidateUserBalance'),
array('option' => array('value' => '0')),
'nothing',
'/option',
array('option' => array('value' => '1', 'selected' => 'selected')),
'some',
'/option',
array('option' => array('value' => '100')),
'a lot',
'/option',
'/select',
'/div'
);
$this->assertTags($result, $expected);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -1006,12 +1006,17 @@ public function input($fieldName, $options = array()) {
}
$options['options'] = $varOptions;
}

if ($options['type'] === 'select' && array_key_exists('step', $options)) {
unset($options['step']);
}
}

$autoLength = (
!array_key_exists('maxlength', $options) &&
isset($fieldDef['length']) &&
is_scalar($fieldDef['length'])
is_scalar($fieldDef['length']) &&
$options['type'] !== 'select'
);
if ($autoLength && $options['type'] == 'text') {
$options['maxlength'] = $fieldDef['length'];
Expand Down

0 comments on commit 5064601

Please sign in to comment.