TinyEditor - using $_POST

848 views Asked by At

Well, I have this code:

<?php 
 if(isset($_POST['texto'])) {
 $texto =  $_POST['texto'];
echo "$texto";

 ?>
 <form action="/env_not.php" method="POST">
<textarea id="tinyeditor" name="texto" style="width: 700px; height: 800px"></textarea>
<script>
var editor = new TINY.editor.edit('editor', {
    id: 'tinyeditor',
    width: 700,
    height: 800,
    cssclass: 'tinyeditor',
    controlclass: 'tinyeditor-control',
    rowclass: 'tinyeditor-header',
    dividerclass: 'tinyeditor-divider',
    controls: ['bold', 'italic', 'underline', 'strikethrough', '|', 'subscript', 'superscript', '|',
        'orderedlist', 'unorderedlist', '|', 'outdent', 'indent', '|', 'leftalign',
        'centeralign', 'rightalign', 'blockjustify', '|', 'unformat', '|', 'undo', 'redo', 'n',
        'font', 'size', 'style', '|', 'image', 'hr', 'link', 'unlink', '|', 'print'],
    footer: true,
    fonts: ['Verdana','Arial','Georgia','Trebuchet MS'],
    xhtml: true,
    cssfile: 'custom.css',
    bodyid: 'editor',
    footerclass: 'tinyeditor-footer',
    toggle: {text: 'source', activetext: 'wysiwyg', cssclass: 'toggle'},
    resize: {cssclass: 'resize'}
});
</script>  <input type='submit' style='text-align: right' name='enviar' value='Enviar'>
  </form>

When I submit this form, my $_POST['texto'] return is blank, how I can pass the value into TinyEditor, to my textarea.texto? Because I need get this value with PHP.

Thanks!

3

There are 3 answers

0
Frederick Corazao On

Well, it's been a while but I'll answer with what I found. Maybe it will help someone in the future.

I had the same problem and then I found that you have to click "source" (to view the html) and then submit. If not, it won't save what you wrote. No idea why this happens, I'm looking for help with this issue myself.

0
Marc Siedler On

You need to add .. onsubmit="editor.post()" .. in your form to get the content of the wysiwyg-editor. For the wysiwyg-mode an iframe-structure is been built dynamically. The value of your textarea-object is not getting changed while being in wysiwyg-mode. Only in source-mode. Hope that helps.

0
Mohammed Sufian On

TRY THIS IT WORKS FOR ME:

 <form action="/env_not.php" method="POST">
 <textarea id="texto" name="texto" style="width: 700px; height: 800px"></textarea>
 <script>
 var texto = new TINY.editor.edit('texto', {
  id: 'texto',
  width: 700,
  height: 800,
  cssclass: 'tinyeditor',
  controlclass: 'tinyeditor-control',
  rowclass: 'tinyeditor-header',
  dividerclass: 'tinyeditor-divider',
  controls: ['bold', 'italic', 'underline', 'strikethrough', '|', 'subscript', 'superscript', '|',
    'orderedlist', 'unorderedlist', '|', 'outdent', 'indent', '|', 'leftalign',
    'centeralign', 'rightalign', 'blockjustify', '|', 'unformat', '|', 'undo', 'redo', 'n',
    'font', 'size', 'style', '|', 'image', 'hr', 'link', 'unlink', '|', 'print'],
  footer: true,
  fonts: ['Verdana','Arial','Georgia','Trebuchet MS'],
  xhtml: true,
  cssfile: 'custom.css',
  bodyid: 'editor',
  footerclass: 'tinyeditor-footer',
  toggle: {text: 'source', activetext: 'wysiwyg', cssclass: 'toggle'},
  resize: {cssclass: 'resize'}
 });
 $('#enviar').click(function() {
   texto.post();
 });
</script>  
<input type='submit' style='text-align: right' name='enviar' id='enviar' value='Enviar'>
</form>