Forums

WYSIWYG editor in Chrionoforms - any more pointers?

buckwheatpie 28 Sep, 2009
Hi,

I've read the thread at http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=12085 and tried various things but am still stuck...

I currnetly have a textarea field called ProjectDesc. I would really really like this field to have the WYSIWYG editor to enable users to jazz up their submissions a little.

I have got as far as inserting the code to display the editor:
<?php
$editor =& JFactory::getEditor();
echo $editor->display( 'fulltext',  '<div>default value</div>', '80%', '350', '55', '20', false  ) ;
?>


However, i can't get submissions to save to the database - i have read the documentation at http://docs.joomla.org/How_to_use_the_editor_in_a_component which hasn't helped me too much - is there a simple way of doing this?

Many thanks!
GreyHead 28 Sep, 2009
Hi buckwheatpie,

Later in that thread I posted a link to this article - the 'Save the Data' section specifically. There may be a better solution here in the forums too.

Bob
buckwheatpie 29 Sep, 2009
Hi bob,

cheers - in the end it was very simple - i just replaced my original textarea code with the following

<?php
$editor =& JFactory::getEditor();
echo $editor->display( 'ProjectDesc',  '<div>default value</div>', '80%', '350', '55', '20', false  ) ;
?>


where ProjectDesc is the name of the field. I don't know if this was necessary but i also opened the database with PhpMyAdmin and changed the ProjectDesc field type from VARCHAR(2000) to MEDIUMTEXT.

It now works fine, my users can format their submissions to their hearts' content, and all their formattings appear in the Chronoconnectivity data display.

Only prob is that if they enter the wrong Captcha, or if their is a validation prob with any of the other fields, the ProjectDesc field (the one with the WYSIWYG editor) doesn't automatically refill - until i fix this i've put a note encouragig them to copy their entry before clicking "submit" so that they don't lose it.
GreyHead 29 Sep, 2009
Hi buckwheatpie,

You can probably get the previous value back by changing the default text in there to grab any exisiting value from the $_POST array.

Bob
buckwheatpie 30 Sep, 2009
Solved! great, cheers.

code now reads:
<?php
$initialentry=$_POST['ProjectDesc'];
if ($initialentry=="")
    $initialentry='Enter your description here';
$editor =& JFactory::getEditor();
echo $editor->display( 'ProjectDesc',  $initialentry, '80%', '350', '55', '20', false  ) ;
?>
beillard 24 Feb, 2010
Hi,

I used this code in my form, It works perfectly.
However, when I modify the content of one form ( I use Profile pluging) I need to refill the wysiwyg editor with the content of one field.

I tryed this code :
<?php

$initialentry = {introtext} ;
 if ($initialentry=="")
$initialentry='Votre introduction...';
$editor =& JFactory::getEditor(tinymce);
echo $editor->display( 'introtext',  $initialentry, '80%', '350', '55', '20', false  ) ; 
?>


I got a Parse error since the content of {introtext} is text

Thanks for help.

André
GreyHead 24 Feb, 2010
Hi André,

I don't think that you can use the {input_name} syntax there - doesn't buckwheatpies' code work ?

Bob
nml375 24 Feb, 2010
Hi André & Bob,
Since we're dealing with the Profile plugin, reading from the $_POST array would not be a very good idea..
Unfortunately, the way the profile-plugin works, the {name} substitution is done after any php-code is evaluated (assuming you've enabled the evaluate setting for the plugin). Setting the "Evaluate code" setting to no should sort this issue. Still, {introtext} will be substituted with the actual text, not something php-friendly. Since this will most likely not contain escaped ' or ", we're still pretty much screwed :/

What to try next?
Well, there's no neat way around this, except dropping the Profile plugin (atleast for this field). You'll have to add the appropriate php-code to fetch the needed data from the database, and echo it into the proper places all through the form code. There should be quite a few good examples on how to do this lurking all over the forum.

/Fredrik
beillard 25 Feb, 2010
Hi Bob, Hi Fredrik,

Thanks for help.
The code works if data is Integer but not with ASCI code.

I'll fetch data from database... Even if I would like avoid this method.

Regards

André
This topic is locked and no more replies can be posted.