mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Merge branch 'issue8654' into 2.x
Removes empty string elements from the secured field list, as in 3.x
This commit is contained in:
commit
a366ac1f66
2 changed files with 27 additions and 1 deletions
|
@ -1619,6 +1619,29 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertEquals(1, $this->Form->fields['Contact.id'], 'Hidden input should be secured.');
|
||||
}
|
||||
|
||||
/**
|
||||
* test unlockField removing from fields array. multiple field version.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUnlockMultipleFieldRemovingFromFields() {
|
||||
$this->Form->request['_Token'] = array(
|
||||
'key' => 'testKey',
|
||||
'unlockedFields' => array()
|
||||
);
|
||||
$this->Form->create('Order');
|
||||
$this->Form->hidden('Order.id', array('value' => 1));
|
||||
$this->Form->checkbox('Ticked.id.');
|
||||
$this->Form->checkbox('Ticked.id.');
|
||||
|
||||
$this->assertEquals(1, $this->Form->fields['Order.id'], 'Hidden input should be secured.');
|
||||
$this->assertTrue(in_array('Ticked.id', $this->Form->fields), 'Field should be secured.');
|
||||
|
||||
$this->Form->unlockField('Order.id');
|
||||
$this->Form->unlockField('Ticked.id');
|
||||
$this->assertEquals(array(), $this->Form->fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* testTagIsInvalid method
|
||||
*
|
||||
|
|
|
@ -663,7 +663,10 @@ class FormHelper extends AppHelper {
|
|||
if (!$field) {
|
||||
$field = $this->entity();
|
||||
} elseif (is_string($field)) {
|
||||
$field = Hash::filter(explode('.', $field));
|
||||
$field = explode('.', $field);
|
||||
}
|
||||
if (is_array($field)) {
|
||||
$field = Hash::filter($field);
|
||||
}
|
||||
|
||||
foreach ($this->_unlockedFields as $unlockField) {
|
||||
|
|
Loading…
Add table
Reference in a new issue