Fix blackhole requests with empty select boxes.

When a select box was entirely empty (no option element)
secured form submission should not fail.

Fixes #3153
This commit is contained in:
mark_story 2012-08-26 22:53:48 -04:00
parent b68a2ed84d
commit cbb64bd082
2 changed files with 31 additions and 2 deletions

View file

@ -4256,6 +4256,30 @@ class FormHelperTest extends CakeTestCase {
$this->assertRegExp('/"' . $key . '"/', $result);
}
/**
* When a select box has no options it should not be added to the fields list
* as it always fail post validation.
*
* @return void
*/
public function testSelectNoSecureWithNoOptions() {
$this->Form->request['_Token'] = array('key' => 'testkey');
$this->assertEquals(array(), $this->Form->fields);
$this->Form->select(
'Model.select',
array()
);
$this->assertEquals(array(), $this->Form->fields);
$this->Form->select(
'Model.select',
array(),
array('empty' => true)
);
$this->assertEquals(array('Model.select'), $this->Form->fields);
}
/**
* testInputMultipleCheckboxes method
*