How to display apostrophe instead of HTML when using set_value default value? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to display apostrophe instead of HTML when using set_value default value? (/showthread.php?tid=49848) |
How to display apostrophe instead of HTML when using set_value default value? - El Forum - 03-05-2012 [eluser]benners[/eluser] It seems when using set_value, if I have an apostrophe in the default value it displays in the input as ' Does anyone know a way around this? html_entity_decode doesn't seem to help. Code: $data = array( HTML returned Code: <input type="text" size="50" maxlength="100" value="Who&#39;s" name="0[title]"> How to display apostrophe instead of HTML when using set_value default value? - El Forum - 03-05-2012 [eluser]porquero[/eluser] Is better way don't encode/decode strings. I recomend you to use utf-8 encoding. Some tips: Files must have utf-8 charset with unix(lf) AND use html metas: Code: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> AND Use Database charsert utf-8. If you use Mysql: "SET NAMES utf8" ALSO you can use .htaccess to force default charset: AddDefaultCharset UTF-8 More info: Search for "UTF-8: The Secret of Character Encoding" How to display apostrophe instead of HTML when using set_value default value? - El Forum - 03-05-2012 [eluser]benners[/eluser] It looks like everything is utf8 database.php Code: $db['default']['char_set'] = 'utf8'; config.php Code: $config['charset'] = 'utf-8'; template_head.php Code: <meta http-equiv="content-type" content="text/html; charset=utf-8" /> The apostrophe is only converted when added passed through the set_value function. How to display apostrophe instead of HTML when using set_value default value? - El Forum - 03-05-2012 [eluser]porquero[/eluser] So you don't need convert apostrophe to set value. Are you try without html_entity_decode function? Remember that files charset must be utf-8 encoded too. If you use geany you can see it status bar. How to display apostrophe instead of HTML when using set_value default value? - El Forum - 03-05-2012 [eluser]Aken[/eluser] Most form helper functions, including set_value(), utilize the htmlspecialchars() function to make sure that anything that has special meaning to HTML is displayed properly when put back into your forms (which is the purpose of set_value()). For instance, say you wanted to save the entity version of an & sign, which is & - if you loaded that into your HTML without any encoding, it would display as a & symbol, which is how your browser interprets it. This is normal functionality - I'm not sure why you're trying to undo it. When your form is processed, those characters should not be there - it should go through POST as their encoded versions. How to display apostrophe instead of HTML when using set_value default value? - El Forum - 03-06-2012 [eluser]benners[/eluser] I'm pulling in the data from the database into an update form. It shows as a Who's there in the database and in the array I populate with the data, but the input on the update form shows Who&#39;s when passed through set_value(). I obviously don't want the users to see it like this. How to display apostrophe instead of HTML when using set_value default value? - El Forum - 03-08-2012 [eluser]benners[/eluser] If I comment out line 646 in form_helper.php the apostrophe's display fine in the input. Line 646: $str = htmlspecialchars($str); Obviously I don't want to modify system files, so how can I get apostrophes to display correctly when using set_value and form validation? How to display apostrophe instead of HTML when using set_value default value? - El Forum - 03-08-2012 [eluser]aquary[/eluser] Value: "Who's" html_entity_decode() returns Who& #39;s (space added to avoid conversion) set_value() of the above returns Who& amp;#39;s (space added to avoid conversion) Sure you will see & amp;#39; instead of ' remove the html_entity_decode(), and everythin will works correctly. How to display apostrophe instead of HTML when using set_value default value? - El Forum - 03-08-2012 [eluser]benners[/eluser] Ahh! Stupid mistake. The field name in set_value was not the same as for 'name'. I would have thought this wouldn't show anything or give an error, but it just did something to the apostrophes. Code: $data = array( Sorry to waste people's time. |