tel8618217223380 / prado3

Automatically exported from code.google.com/p/prado3
Other
0 stars 0 forks source link

Include additional text when localizing a validator's text #449

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I would like to add additional text/HTML code when localizing a validator's 
text. For example, i want to add a <br>

example 1 (working):
<com:TRequiredFieldValidator ControlToValidate="email" Text="<%[Please enter 
your email address!]%>" />

example 2 (not working):
<com:TRequiredFieldValidator ControlToValidate="email" Text="<%[Please enter 
your email address!]%><br>" />

This seems to be rooted in TTemplate::parseAttribute(), line 896:

> else 
if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$valu
e,$matches) && $matches[0]===$value)

There, it correctly matches the localization tag but checks if the $matches[0] 
equals $value, which isn't true for the second example because:

$matches[0] is "<%[Please enter your email address!]%>" but
$value is "<%[Please enter your email address!]%><br>".

Is there a possibility to fix this?

Thanks,
Raoul

Original issue reported on code.google.com by ra...@bhatia.at on 14 Mar 2013 at 6:11

GoogleCodeExporter commented 9 years ago
Adding the check for a prefix/suffix is something that can be done.
Unfortunately in the current implementation the parsing code is shared between 
different kind of tags (asset, localization, parameter, expression tags), and 
this makes any change to the code potentially dangerous: it will need a lot of 
testing.
In the meanwhile, a quick workaround is to use <%=  Prado::localize('Please 
enter your email address!')."<br/>" %> instead.

Original comment by ctrlal...@gmail.com on 16 Mar 2013 at 3:16

GoogleCodeExporter commented 9 years ago
i agree.
maybe more tests in this regard would be needed...
or a seperate elseif branch ;)

Original comment by ra...@bhatia.at on 16 Mar 2013 at 4:04

GoogleCodeExporter commented 9 years ago
Moved to github: https://github.com/pradosoft/prado/issues

Original comment by ctrlal...@gmail.com on 1 Oct 2013 at 10:14