& to & in text fields

5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 25, 2009   (RSS)

Re: [rjbathgate] & to & in text fields

By Kenny - March 25, 2009

Rob,

I'm not able to duplicate your problem.

Whenever I type in &amp it displays as &

I have tested this on a textbox and text field using version 1.27

Kenny

Re: [sagentic] & to & in text fields

Ha you're right, it works now...

Perhaps it's been fixed in an update of the CMSB... or when I was trying it, I'd done something wrong...

Note it needs to be & to validate (with the ;)

While this works, it's not ideal from userability point of view - can't expect the client to type & instead of &, so ideally it'd be good if it can still auto turn "&" into &

Cheers :)

Re: [rjbathgate] & to & in text fields

By Dave - March 25, 2009

Hi Rob,

We store user input exactly as it is entered because we don't know what the output medium might be (web page, xml, email, etc). So if you enter & it will be stored (and output) as &.

You can automatically encode output as html entities with the php function htmlspecialchars(). So instead of this:
<?php echo $record['title'] ?>

You could have:
<?php echo htmlspecialchars($record['title']) ?>

For more details see: http://www.php.net/htmlspecialchars

Hope that helps, let me know if that does what you need.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] & to &amp; in text fields

Excellent :)

Will give that a play, cheers Dave!