1
marcan
XoopsFormText and this symbol : '
  • 2004/3/17 19:57

  • marcan

  • Just can't stay away

  • Posts: 824

  • Since: 2003/10/8


I've found something that seems like a bug, but I'm not sure. However, it is really anoying. Let me explain.

When using the class XoopsFormText, there is a bug with this symbol ' (Sorry, don't know what it is in english...)

For example :
$sform -> addElement( new XoopsFormText( _AM_SB_COLNAME, 'name', 50, 255, $name ), true );

Let's suppose that $name = "Let's go !".

The text box created with the previous code will have this default value : "Let". All the caracters after the ' symbol are autmatically truncated.

Now, I search a bit further. On the page where the text box was display, I checked the Page Source. Here is what I found : the textbox html code looks like this :
'Let's go !' />

Do you see the problem now? There's too much of these ' symbols there !

Now, I looked at the code that generate this html, in class/xoopsform/formtext.php :
(...) value='".$this->getValue()."'".$this->getExtra()." />";

Is there something I can do?

Thanks for any help !

2
Dave_L
Re: XoopsFormText and this symbol : '
  • 2004/3/17 20:41

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


In English, that symbol is called an apostrophe, or sometimes a single quote. Try replacing each occurrence of an apostrophe with its HTML entity code:

[color=ff0000]$name str_replace(''', 'a p o s ;', $name);[/color]
$sform->addElement(new XoopsFormText(_AM_SB_COLNAME, '
name', 50, 255, $name), true);


But remove the spaces in & a p o s ;. I had to use spaces so that it would display here.

3
marcan
Re: XoopsFormText and this symbol : '
  • 2004/3/17 20:50

  • marcan

  • Just can't stay away

  • Posts: 824

  • Since: 2003/10/8


Dave_L : thanks for your help !

I've tried the folowing :
$newname = str_replace("'", ''', $name);
$sform -> addElement( new XoopsFormText( _AM_XH_COLNAME, 'name', 50, 255, $newname), true );

$newname = str_replace("'", "'", $name);
$sform -> addElement( new XoopsFormText( _AM_XH_COLNAME, 'name', 50, 255, $newname), true );

$newname = str_replace("'", "''", $name);
$sform -> addElement( new XoopsFormText( _AM_XH_COLNAME, 'name', 50, 255, $newname), true );

$newname = str_replace("'", "'''", $name);
$sform -> addElement( new XoopsFormText( _AM_XH_COLNAME, 'name', 50, 255, $newname), true );

All without any success. Do you have another idea ?

Thanks for your help !

4
Dave_L
Re: XoopsFormText and this symbol : '
  • 2004/3/17 20:56

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Since the HTML entity won't display "as-is" here, it's hard to tell exactly what code you used.

I had to edit my post above (several times) to fix it. Please recheck that you're using the latest one.


5
marcan
Re: XoopsFormText and this symbol : '
  • 2004/3/17 21:00

  • marcan

  • Just can't stay away

  • Posts: 824

  • Since: 2003/10/8


And it is working my friend !

Thank you very much !

Regards !

6
Dave_L
Re: XoopsFormText and this symbol : '
  • 2004/3/17 21:05

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7




I just checked the PHP manual. A "cleaner" method might be to use the PHP function htmlspecialchars:

$name htmlspecialchars($nameENT_QUOTES);

Login

Who's Online

298 user(s) are online (184 user(s) are browsing Support Forums)


Members: 0


Guests: 298


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits