Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improving test coverage on FormHelper to show the usage of the 'secur…

…e' key for inputs.

Fixing issue with select inputs that does not honor the value of 'secure'
  • Loading branch information...
commit 59f7cb47d34f70a6d61947fedf8b18c1a74a24d6 1 parent 7668894
@lorenzo lorenzo authored
View
9 cake/libs/view/helpers/form.php
@@ -1412,6 +1412,9 @@ function select($fieldName, $options = array(), $selected = null, $attributes =
$escapeOptions = $attributes['escape'];
unset($attributes['escape']);
}
+ if (isset($attributes['secure'])) {
+ $secure = $attributes['secure'];
+ }
if (isset($attributes['empty'])) {
$showEmpty = $attributes['empty'];
unset($attributes['empty']);
@@ -1452,7 +1455,9 @@ function select($fieldName, $options = array(), $selected = null, $attributes =
}
if (!empty($tag) || isset($template)) {
- $this->__secure();
+ if (!isset($secure) || $secure == true) {
+ $this->__secure();
+ }
$select[] = sprintf($tag, $attributes['name'], $this->_parseAttributes(
$attributes, array('name', 'value'))
);
@@ -2169,4 +2174,4 @@ function _initInputField($field, $options = array()) {
}
}
-?>
+?>
View
27 cake/tests/cases/libs/view/helpers/form.test.php
@@ -1225,6 +1225,31 @@ function testFormSecuredRadio() {
}
/**
+ * testDisableSecurityUsingForm method
+ *
+ * @access public
+ * @return void
+ */
+ function testDisableSecurityUsingForm() {
+ $this->Form->params['_Token']['key'] = 'testKey';
+ $this->Form->params['_Token']['disabledFields'] = array();
+ $this->Form->create();
+
+ $this->Form->hidden('Addresses.id', array('value' => '123456'));
+ $this->Form->input('Addresses.title');
+ $this->Form->input('Addresses.first_name', array('secure' => false));
+ $this->Form->input('Addresses.city', array('type' => 'textarea', 'secure' => false));
+ $this->Form->input('Addresses.zip', array(
+ 'type' => 'select', 'options' => array(1,2), 'secure' => false
+ ));
+
+ $result = $this->Form->fields;
+ $expected = array(
+ 'Addresses.id' => '123456', 'Addresses.title',
+ );
+ $this->assertEqual($result, $expected);
+ }
+/**
* testPasswordValidation method
*
* test validation errors on password input.
@@ -6173,4 +6198,4 @@ function testInputTemplate() {
$this->assertTags($result, $expected);
}
}
-?>
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.