Skip to content

Commit

Permalink
Fixes yiisoft#4064: Fixed CHtml::beginForm which produced wrong HTML …
Browse files Browse the repository at this point in the history
…when using an anchor in the action URL of a GET form
  • Loading branch information
samdark committed Mar 13, 2017
1 parent 7b44abc commit 9b14ff3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Version 1.1.18 under development
- Bug #4020: Fixed PHP 7 related bug in CCacheHttpSession when destroying not cached sessions (dirx)
- Bug #4034: Fixed `CHttpSession::getIsStarted()` PHP 7 compatibility (tomotomo)
- Bug #4061: Fixed "Fatal Error: Nesting level too deep - recursive dependency" error in `CArrayDataProvider` (kf99916, andrewnester)
- Bug #4064: Fixed CHtml::beginForm which produced wrong HTML when using an anchor in the action URL of a GET form (Mytskine)
- Bug #4069: Fixed error with `eCRedisCache::executeCommand()` when the previous connection timeout exception was catched (taobig)
- Bug #4104: Fixed PHP 7 compatibiltiy in Text_Highlighter (samdark)
- Bug #4111: Fixed PHP 7.1 incompatibility with CFileCache when `$embedExpiry=false` (cebe)
Expand Down
2 changes: 1 addition & 1 deletion framework/web/helpers/CHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public static function beginForm($action='',$method='post',$htmlOptions=array())
$hiddens=array();
if(!strcasecmp($method,'get') && ($pos=strpos($url,'?'))!==false)
{
foreach(explode('&',substr($url,$pos+1)) as $pair)
foreach(explode('&',substr(preg_replace('/#.+$/','',$url),$pos+1)) as $pair)
{
if(($pos=strpos($pair,'='))!==false)
$hiddens[]=self::hiddenField(urldecode(substr($pair,0,$pos)),urldecode(substr($pair,$pos+1)),array('id'=>false));
Expand Down
4 changes: 2 additions & 2 deletions tests/framework/web/helpers/CHtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public static function providerBeginForm()
return array(
array("index", "get", array(), '<form action="index" method="get">'),
array("index", "post", array(), '<form action="index" method="post">'),
array("index?myFirstParam=3&mySecondParam=true", "get", array(),
"<form action=\"index?myFirstParam=3&amp;mySecondParam=true\" method=\"get\">\n".
array("index?myFirstParam=3&mySecondParam=true#anchor", "get", array(),
"<form action=\"index?myFirstParam=3&amp;mySecondParam=true#anchor\" method=\"get\">\n".
"<input type=\"hidden\" value=\"3\" name=\"myFirstParam\" />\n".
"<input type=\"hidden\" value=\"true\" name=\"mySecondParam\" />"),

Expand Down

0 comments on commit 9b14ff3

Please sign in to comment.