Permalink
Browse files

Making some tests relating rendering selects with input() pass

  • Loading branch information...
1 parent 5d6963a commit bc406cc7b5b29cb04153740d877187b10fa34f58 @lorenzo lorenzo committed Feb 23, 2014
Showing with 21 additions and 3 deletions.
  1. +20 −2 src/View/Helper/FormHelper.php
  2. +1 −1 tests/TestCase/View/Helper/FormHelperTest.php
@@ -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') {
@@ -900,6 +900,24 @@ public function input($fieldName, $options = array()) {
}
/**
+ * 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
*
* @param string $fieldName the name of the field to parse options for
@@ -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);
}
@@ -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)
);

0 comments on commit bc406cc

Please sign in to comment.