Pergunta

I want to know if it's possible to get plain text (text without html code) when I submit my form having a ckeditor textarea.

In fact, I want to have a simple textarea with the spellchecker option of ckeditor.

p.s. I am using vtiger 6.

Foi útil?

Solução

It's possible, and given that you're using PHP a decent-ish solution would be HTML Purifier. Assuming you can install it via PEAR (which is the most straightforward way to do it), your example would look like:

require_once 'HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML', 'Allowed', ''); // Allow Nothing
$purifier = new HTMLPurifier($config);
return $purifier->purify($_REQUEST['field_name']);

You're going to want to remove most of the editor buttons and other options from CKeditor as well to prevent your users from adding a lot of formatting that won't survive filtration.

However:

Using the full CKEditor stack for spellcheck is overkill! Why not just use a standalone, jQuery spellchecker like this one?

Outras dicas

You can use the PHP function that strips HTML tags from a string, strip_tags:

$plaintext = strip_tags($_POST['mytexteditor']);

You can also allow certain tags:

$plaintext_with_ps = strip_tags($_POST['mytexteditor'], '<p>');

Don't attempt to use it as a security measure, however.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top