Skip to content

Commit

Permalink
Merge pull request #4001 from totoprayogo1916/fix/form-helper
Browse files Browse the repository at this point in the history
make form_hidden based on form_input
  • Loading branch information
samsonasik authored Dec 19, 2020
2 parents 7479fba + d1ec96a commit f15c92e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion system/Helpers/form_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function form_hidden($name, $value = '', bool $recursing = false): string

if (! is_array($value))
{
$form .= '<input type="hidden" name="' . $name . '" value="' . esc($value) . "\" style=\"display:none;\" />\n";
$form .= form_input($name, $value, '', 'hidden');
}
else
{
Expand Down
12 changes: 6 additions & 6 deletions tests/system/Helpers/FormHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ public function testFormOpenWithHidden()
$Name = csrf_token();
$expected = <<<EOH
<form action="http://example.com/index.php/foo/bar" name="form" id="form" method="POST" accept-charset="utf-8">
<input type="hidden" name="foo" value="bar" style="display:none;" />
<input type="hidden" name="$Name" value="$Value" style="display:none;" />
<input type="hidden" name="foo" value="bar" />
<input type="hidden" name="$Name" value="$Value" />
EOH;
}
Expand All @@ -180,7 +180,7 @@ public function testFormOpenWithHidden()
$expected = <<<EOH
<form action="http://example.com/index.php/foo/bar" name="form" id="form" method="POST" accept-charset="utf-8">
<input type="hidden" name="foo" value="bar" style="display:none;" />
<input type="hidden" name="foo" value="bar" />
EOH;
}
Expand Down Expand Up @@ -242,7 +242,7 @@ public function testFormHidden()
{
$expected = <<<EOH
<input type="hidden" name="username" value="johndoe" style="display:none;" />\n
<input type="hidden" name="username" value="johndoe" />\n
EOH;
$this->assertEquals($expected, form_hidden('username', 'johndoe'));
}
Expand All @@ -255,7 +255,7 @@ public function testFormHiddenArrayInput()
];
$expected = <<<EOH
<input type="hidden" name="foo" value="bar" style="display:none;" />
<input type="hidden" name="foo" value="bar" />
EOH;
$this->assertEquals($expected, form_hidden($data, null));
Expand All @@ -269,7 +269,7 @@ public function testFormHiddenArrayValues()
];
$expected = <<<EOH
<input type="hidden" name="name[foo]" value="bar" style="display:none;" />
<input type="hidden" name="name[foo]" value="bar" />
EOH;
$this->assertEquals($expected, form_hidden('name', $data));
Expand Down

0 comments on commit f15c92e

Please sign in to comment.