Created
September 22, 2010 15:38
-
-
Save ArnaudD/591903 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: lib/widget/sfWidgetFormSchemaOptional.class.php | |
=================================================================== | |
--- lib/widget/sfWidgetFormSchemaOptional.class.php (revision 30918) | |
+++ lib/widget/sfWidgetFormSchemaOptional.class.php (working copy) | |
@@ -36,7 +36,8 @@ | |
protected function getDecorator($name) | |
{ | |
- $strippedName = substr($name, strrpos($name, '[') + 1, strrpos($name, ']') - strrpos($name, '[') - 1); | |
+ $widgetName = substr($name, strrpos($name, '[') + 1, strrpos($name, ']') - strrpos($name, '[') - 1); | |
+ $strippedName = $this->generateId ($name); | |
$decorator = $this->escape($this->decorator); | |
$decorator = " | |
<script type=\"text/javascript\"> | |
@@ -46,7 +47,7 @@ | |
added{$strippedName} += 1; | |
var content = \"{$decorator}\"; | |
var spanTag = document.createElement(\"span\"); | |
- spanTag.innerHTML = content.replace(/([_\[]){$strippedName}([_\]])/g, '\$1{$strippedName}' + + added{$strippedName} + '\$2'); | |
+ spanTag.innerHTML = content.replace(/([_\[]){$widgetName}([_\]])/g, '\$1{$widgetName}' + + added{$strippedName} + '\$2'); | |
document.getElementById('add_{$strippedName}').appendChild(spanTag); | |
document.getElementById('add_{$strippedName}').style.display='block';"; | |
if ($this->getOption('max_additions') > 0) { | |
Index: lib/widget/sfWidgetFormSchemaDecoratorEscaped.class.php | |
=================================================================== | |
--- lib/widget/sfWidgetFormSchemaDecoratorEscaped.class.php (revision 30918) | |
+++ lib/widget/sfWidgetFormSchemaDecoratorEscaped.class.php (working copy) | |
@@ -44,10 +44,8 @@ | |
*/ | |
protected function escape($string) | |
{ | |
- return str_replace( | |
- array("\\" , "\n" , "\r" , "\"" , "'" ), | |
- array("\\\\", "\\n" , "\\r", "\\\"", "\\'"), | |
- $string); | |
+ $string = json_encode($string); | |
+ return substr($string, 1, strlen($string) - 2); // remove first and last double quote | |
} | |
protected function getDecorator($name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment