![]() |
[SOLVED] TinyMCE and Form set_value problem - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: [SOLVED] TinyMCE and Form set_value problem (/showthread.php?tid=26459) Pages:
1
2
|
[SOLVED] TinyMCE and Form set_value problem - El Forum - 01-14-2010 [eluser]jjmax[/eluser] Hi, I'm using TinyMCE on a site I'm building. I want the user to be able to add articles to the site. To this end I've setup a form with some validations. If the validation returns false I want to alert the user, but also want to repopulate the form fields with the data they've already added. This works fine using the set_value() function of the form helper. The only thing is that when the form is reloaded and the fields repopulated the TinyMCE fields are not being formatted properly. For example: If I type the following into a textarea with TinyMCE enabled - Code: How Code: <p>How<br />Now<br />Brown<br />Cow</p> Code: <p>How<br />Now<br />Brown<br />Cow</p> Code: <p>& lt;p & gt;How & lt;br / & gt;Now & lt;br / & gt;Brown & lt;br / & gt;Cow & lt;/p & gt;</p> Can anyone tell me why this is happening and how I can fix it please? Thanks for your time [SOLVED] TinyMCE and Form set_value problem - El Forum - 01-14-2010 [eluser]flaky[/eluser] I'm not very sure of this but if you are inserting the data with Active Record, AR escapes converts html tags to text for security. [SOLVED] TinyMCE and Form set_value problem - El Forum - 01-14-2010 [eluser]Maglok[/eluser] Can you post a little more mabye? Got TinyMCE working on a lot of my apps, is very usefull. The active record class is giving me no problems if I just use the ->input(). My TinyMCE is setup like this: Code: [removed] You kinda have to be doing something with the data before you post it. Perhaps like escaping indeed. [SOLVED] TinyMCE and Form set_value problem - El Forum - 01-14-2010 [eluser]flaky[/eluser] check this post http://ellislab.com/forums/viewthread/139783/ [SOLVED] TinyMCE and Form set_value problem - El Forum - 01-14-2010 [eluser]jjmax[/eluser] Hi Lads, Thanks for the replies. @flaky That last link seems to be pretty much what's happening with me too I'm new to CI, is AR getting involved when I use the Form helper set_value function? @Maglok Thanks for your input I'll try your init on my page. I've setup TinyMCE to edit html content that I've stored in the DB, the only difference here is I'm using set_value as opposed to pulling the data from the DB. I want to prevent my users from creating an articel with the same title as another one, but when I send them back to the article page I want to repopulate the form fields with the data they've already added. Here's the View code - Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Code: function add_article() Thanks again for the help. I'll try out your suggestions and let you know what happens. [SOLVED] TinyMCE and Form set_value problem - El Forum - 01-14-2010 [eluser]flaky[/eluser] Only upon insertion or update AR does that check and modification of the data [SOLVED] TinyMCE and Form set_value problem - El Forum - 01-14-2010 [eluser]jjmax[/eluser] Thanks for the reply flaky. I've been working on this a bit more, and when I past HTML code directly into the TinyMCE textarea it appears as the HTML code. So - Code: <p>howya</p> Is shown as this in the WYSIWYG editor - Code: <p>howya</p> And this in the html editor - Code: <p>&-lt;p&-gt;howya&-lt;/p&-gt;<br />&-lt;ol&-gt;<br />&-lt;li&-gt;Yer&-lt;/li&-gt;<br />&-lt;li&-gt;a&-lt;/li&-gt;<br />&-lt;li&-gt;hero&-lt;/li&-gt;<br />&-lt;/ol&-gt;</p> The dashes after the ampersands are there to stop the html entities being changed. [SOLVED] TinyMCE and Form set_value problem - El Forum - 01-14-2010 [eluser]Ben Edmunds[/eluser] Hey John, In your article controller try using $_POST['data'] instead of $this->input->post('data') or set_value('data'). If that doesn't work please post your article/index controller code. [SOLVED] TinyMCE and Form set_value problem - El Forum - 01-14-2010 [eluser]jjmax[/eluser] Hi Ben, Thanks for the reply. I changed the controller to save posted data on fail, and then changed the view to use the $_POST data to repopulate the fields. This works as in the repopulation occurs, but the problem with html code still exists in the textarea. I can repopulate inputs and textareas that don't have tinymce enabled on them, but repopulating a tinmce enabled field results in the html being being displayed in the WYSIWYG editor and being converted to html entities in the html editor. TinyMCE must have a setting somewhere to stop this happening. Funnily though when I setup the edit controller to edit existing pages, the html from the db is being displayed properly. Why would TinyMCE be differentiating between html pulled from the DB and html pasted straight into it or taken from $_POST? All the best, John [SOLVED] TinyMCE and Form set_value problem - El Forum - 01-14-2010 [eluser]flaky[/eluser] the change occurs in the Active Record not in $this->input->post('some_var'); so you should insert the data with a query example Code: $title = $this->input->post('title'); but keep in mind this isn't very secure. |