Skip to content

Commit

Permalink
fix form helper set_radio
Browse files Browse the repository at this point in the history
  • Loading branch information
andreifurrnica committed Aug 2, 2018
1 parent 25922b5 commit 6b6703d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion system/Helpers/form_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ function set_radio(string $field, string $value = '', bool $default = false): st

// Unchecked checkbox and radio inputs are not even submitted by browsers ...
$result = '';
if (!empty($request->getPost()) || !empty(old($field)))
if (!empty($input = $request->getPost($field)) || !empty($input = old($field)))
{
$result = ($input === $value) ? ' checked="checked"' : '';
}
Expand Down
8 changes: 8 additions & 0 deletions tests/system/Helpers/FormHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,10 @@ public function testSetCheckbox()
}

// ------------------------------------------------------------------------
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testSetRadio()
{
$_SESSION = [
Expand All @@ -771,6 +775,10 @@ public function testSetRadio()
unset($_SESSION['_ci_old_input']);
}

/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testSetRadioFromPost()
{
$_POST['bar'] = 'baz';
Expand Down

0 comments on commit 6b6703d

Please sign in to comment.