I’m using Ckeditor version 3.1 within CakePHP 2.x
I can get the editor to load and replace the textarea. The HTML is saved to the database with HTML formatting tags like this:
<p>
<strong><p> This is a test</p> </strong></p>
When I insert that into the CkEditor I get the following appearing in the editor screen:
<p> <strong><p> This is a test</p> </strong></p>
If I use html_entity_decode prior to setting up the CkEditor I get this in the editor screen:
<p> <strong><p> This is a test</p> </strong></p>
This is how I am loading the editor in the edit.ctp Cake view:
$bio = $this->data['Club']['bio'];
echo $this->Cksource->ckeditor('Club.bio', array('value'=>$bio) );
How can I force CkEditor to parse the incoming HTML so that it is formatted and not displaying the HTML tags?
Edit:
I have manually overwritten the Cake Helper so that the Javascript being output looks like this:
CKEDITOR.replace('data[Club][bio]',
{
entities: false,
basicEntities: false,
entities_greek: false,
entities_latin: false,
htmlDecodeOutput: true
}
);
The appropriate form field is being converted to a ckeditor instance so the first parameter is correct, I assume. I’ve also tried to update config.js without any luck.
Thanks Harry – you helped with the setup. I had to tweak the Cake stuff to get the Javascript looking like you said it should.
Anyway here’s something that is working for me:
I would imagine it is not really necessary to put the value in when echoing out the editor.
I kept getting a Javascript error when trying to setData (“unexpected ILLEGAL tag”) which is why I strip out excess whitespace – which fixes that issue.