Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Making some tests relating rendering selects with input() pass
  • Loading branch information
lorenzo committed Feb 23, 2014
1 parent 5d6963a commit bc406cc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions src/View/Helper/FormHelper.php
Expand Up @@ -883,7 +883,7 @@ public function input($fieldName, $options = array()) {
}

$groupTemplate = $options['type'] === 'checkbox' ? 'checkboxFormGroup' : 'formGroup';
$input = $this->{$options['type']}($fieldName, $options);
$input = $this->_getInput($fieldName, $options);
$result = $this->formatTemplate($groupTemplate, compact('input', 'label'));

if ($options['type'] !== 'hidden') {
Expand All @@ -899,6 +899,24 @@ public function input($fieldName, $options = array()) {
return $result;
}

/**
* Generates an input element
*
* @param string $fieldName the field name
* @param array $options The options for the input element
* @return string The generated input element
*/
protected function _getInput($fieldName, $options) {
switch ($options['type']) {
case 'select':
$opts = $options['options'];
unset($options['options']);
return $this->select($fieldName, $opts, $options);
default:
return $this->{$options['type']}($fieldName, $options);
}
}

/**
* Generates input options array
*
Expand Down Expand Up @@ -1675,7 +1693,7 @@ public function select($fieldName, $options = [], $attributes = []) {
);
$hidden = $this->hidden($fieldName, $hiddenAttributes);
}
unset($attributes['hiddenField']);
unset($attributes['hiddenField'], $attributes['type']);
return $hidden . $this->widget('select', $attributes);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -3161,7 +3161,7 @@ public function testInputWithLeadingInteger() {
* @return void
*/
public function testInputSelectType() {
$this->markTestIncomplete('Need to revisit once models work again.');
$this->markTestIncomplete('A test here is throwing fatal error, fix later');
$result = $this->Form->input('email', array(
'options' => array('è' => 'Firést', 'é' => 'Secoènd'), 'empty' => true)
);
Expand Down

0 comments on commit bc406cc

Please sign in to comment.