BUG 6913 Suggest fied problem with characteres like #, $ and & is solved

This commit is contained in:
Erik Amaru Ortiz
2011-05-19 10:58:55 -04:00
parent c2c0414702
commit c218dad390
4 changed files with 39 additions and 7 deletions

View File

@@ -471,7 +471,12 @@ _b.AutoSuggest.prototype.setHighlightedValue = function ()
{
if (this.iHigh)
{
this.sInp = this.fld.value = this.aSug[ this.iHigh-1 ].value;
/**
* @autor Erik Amaru Ortiz <erik@colosa.com>
* This fix when a item on suggestion list have html wntities sent by json like &amp;
*/
this.sInp = this.fld.value = html_entity_decode(this.aSug[ this.iHigh-1 ].value);;
//
// move cursor to end of input (safari)
//
@@ -493,7 +498,7 @@ _b.AutoSuggest.prototype.setHighlightedValue2 = function ()
{
if (this.iHigh)
{
this.sInp = this.fld.value = this.aSug[ this.iHigh-1 ].value;
this.sInp = this.fld.value = html_entity_decode(this.aSug[ this.iHigh-1 ].value);
// move cursor to end of input (safari)
//
@@ -772,4 +777,24 @@ function storeEntry(o, cnn, table, pk, pkt, fld){
//alert(req)
} );
}
}
}
function html_entity_decode( string, quote_style ) {
var histogram = {}, symbol = '', tmp_str = '', entity = '';
tmp_str = string.toString();
if (false === (histogram = get_html_translation_table('HTML_ENTITIES', quote_style))) {
return false;
}
// &amp; must be the last character when decoding!
delete(histogram['&']);
histogram['&'] = '&amp;';
for (symbol in histogram) {
entity = histogram[symbol];
tmp_str = tmp_str.split(entity).join(symbol);
}
return tmp_str;
}

View File

@@ -1153,7 +1153,7 @@ class XmlForm_Field_Suggest extends XmlForm_Field_SimpleText //by neyek
$setValue = ($this->savelabel == '1')? 'obj.value': 'obj.id';
$sOptions .= 'callback: function(obj){getField(\''.$this->name.'\').value='.$setValue.';'.$sCallBack.'; return false;}';
$sOptions .= 'callback: function(obj){'.$sCallBack.'; return false;}';
$str .= '<script type="text/javascript">';
$str .= 'var as_json = new bsn.AutoSuggest(\'form[' . $this->name . ']\', {'.$sOptions.'});';

View File

@@ -119,6 +119,13 @@
{$PME_PRIMARY_KEY_TYPE} {$form.PME_PRIMARY_KEY_TYPE}
</td>
</tr>
<tr>
<td class='FormLabel' width="{$form_labelWidth}">{$PME_CALLBACK}</td>
<td class='FormFieldContent' width='{$form_fieldContentWidth}' >{$form.PME_CALLBACK}</td>
</tr>
<tr>
{$form.PME_TABLE_DATA}{$form.PME_PRIMARY_KEY_DATA}{$form.PME_PRIMARY_KEY_TYPE_DATA}{$form.PME_FIELD}
<td class='FormButton' colspan="2" align="center"> {$form.PME_ACCEPT} &nbsp; {$form.BTN_CANCEL} </td>

View File

@@ -127,9 +127,9 @@ SELECT XMLNODE_NAME, TYPE FROM dynaForm WHERE XMLNODE_NAME = @@PME_XMLNODE_NAME
</en>
</PME_PRIMARY_KEY_TYPE>
<!--<PME_CALLBACK type="textarea" cols="40" rows="2">
<en>Javascript routine callback</en>
</PME_CALLBACK>-->
<PME_CALLBACK type="textarea" cols="40" rows="2">
<en>Javascript callback to execute by a selection</en>
</PME_CALLBACK>
<BTN_CANCEL type="button" onclick="cancel();">
<en>Cancel</en>