Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.2.16

Request #1971 Allow {jsVar} substitution in HTML_QuickForm_RuleRegistry::getValidationScript
Submitted: 2004-07-24 03:18 UTC
From: studio at peptolab dot com Assigned:
Status: Wont fix Package: HTML_QuickForm
PHP Version: Irrelevant OS: Any
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 28 - 4 = ?

 
 [2004-07-24 03:18 UTC] studio at peptolab dot com
Description: ------------ When creating a subclass of HTML_QuickForm_Rule, I was trying to reference the {jsVar} in my prefix code, however the HTML_QuickForm_RuleRegistry:: getValidationScript only performs a str_replace on the $jsCheck variable, not $jsPrefix. Is it possible to modify the code to allow substitution for the prefix? It does not matter if 'value' is a string/number or an array, as that can be determined on the client-side JavaScript. Reproduce code: --------------- Line 179-180: $js = $jsValue . "\n" . $jsPrefix . " if (" . str_replace('{jsVar}', 'value', $jsCheck) . " && !errFlag['{$jsField}']) {\n" . change to:- $js = $jsValue . "\n" . str_replace('{jsVar}', 'value', $jsPrefix) . " if (" . str_replace('{jsVar}', 'value', $jsCheck) . " && !errFlag['{$jsField}']) {\n" . Line 186-187: $js = $jsValue . "\n" . $jsPrefix . " var res = 0;\n" . change to:- $js = $jsValue . "\n" . str_replace('{jsVar}', 'value', $jsPrefix) . " var res = 0;\n" . Expected result: ---------------- To substitute the {jsVar} string with the name of the actual form element Actual result: -------------- Not implemented as yet

Comments

 [2004-10-10 14:09 UTC] avb
The only point of having a {jsVar} substituton in $jsCheck is because it can be either 'value' or 'value[i]'. As $jsPrefix is outside the JS loop, it can only be 'value'. Substituting different strings for the same placeholder can only be confusing. You can simply use 'value' within your $jsPrefix code.