Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
form_hidden based on form_input
Browse files Browse the repository at this point in the history
totoprayogo1916 committed Dec 19, 2020
1 parent 7479fba commit 1a715d3
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions system/Helpers/form_helper.php
Original file line number Diff line number Diff line change
@@ -143,7 +143,7 @@ function form_hidden($name, $value = '', bool $recursing = false): string

if ($recursing === false)
{
$form = "\n";
$form = "\r";
}

if (is_array($name))
@@ -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
{
12 changes: 6 additions & 6 deletions tests/system/Helpers/FormHelperTest.php
Original file line number Diff line number Diff line change
@@ -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;
}
@@ -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;
}
@@ -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'));
}
@@ -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));
@@ -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));

0 comments on commit 1a715d3

Please sign in to comment.