The Wysiwyg and CCK multiple value fields

Setting up a Wysiwyg or rich text editor in Drupal is a straightforward task: you download the Wysiwyg module along with the library of your favorite editor and you're good to go. You will run into issues when you're using CCK multiple value fields though:

  • You will experience data loss when adding more fields: all content added to existing fields will disappearing when you click the "Add another item" button to add a new field.
  • Depending on which editor you use, there's a chance of hick-ups and data loss when using the drag-and-drop interface to rearrange fields.
  • Depending on which editor you use, you will run into different kinds of unexpected behaviors when adding your first new item after clicking the "Add another item" button. These issues can range from the editor only appearing on the first field, to only appearing on the last field, or from the editor disappearing completely.

The first two issues can be fixed by installing the Wysiwyg API CCK Integration module, which itself depends on three other modules: JS Alter, jQuery Form Update and jQuery AOP. These modules require no configuration: just enable them to fix the problems.

The third issue however is more tedious. I've tried fixing the bug with hook_form_alter() and CCK fields along with the Wysiwyg integration guide but these don't play along nicely. The added difficulty is that the problem varies depending on which editor you use. The only bulletproof "solution" I've found this far is to simply use the FCKeditor editor: it's the only editor that doesn't appear to cause any unexpected behavior. Do note that these problems are only fixed if you use the FCKeditor with the Wysiwyg module: the FCKeditor module itself still has these issues.

Comments

Thanks for this informative and to the point guide.

Title says it all.

Great post-- but its a shame

Great post-- but its a shame really. To expect joe user to jump through these hoops just to get a fully functional wysiwyg editor working properly is pretty unreasonable.

Let's not forget that the

Let's not forget that the wysiwyg works perfectly by itself on the body of the node and on fields that don't have multiple values of course.

Not all it-- it's an amazing

Not all it-- it's an amazing piece of work and light years ahead of what it was like to get wysiwyg working in d5. But the fact remains fields/multivalue fields are one of the great things about drupal and for joe user to have to figure this out and install 3 extra modules or change editors is why drupal still has the rep of being noob unfriendly.

Thanks for the tip. With

Thanks for the tip. With fckeditor, do you perhaps mean ckeditor? Does fckeditor still exist?

It only works with FCKeditor,

It only works with FCKeditor, and sadly not with the newer CKEditor. It still exists yes, as the latest stable version:

FCKeditor 2.6.6, released on 15 February 2010

Bounty

I'm happy to contribute a bounty toward getting this fixed properly, let's say $100 USD. Is anyone else willing to contribute?

Although it's fantastic you found a solution, I'm not sure I understand what's even going wrong here.

Would a module that implemented the following procedure help?
- Add more clicked
- Disable all WYSIWYG editors on page
- Reload the HTML form (as normal)
- Re-enable all WYSIWYG editors

The Wysiwyg API CCK

The Wysiwyg API CCK Integration module already does what you sugges, and that does take care of the data loss issue. The other - and not so easy to solve - issue is that each editor (TinyMCE, CKEditor, FCKeditor, ...) has a different way of attaching itself to a textarea. It might be interesting to see how FCKeditor does this and how it differs from, for instance, CKEditor.

Post new comment

The content of this field is kept private and will not be shown publicly.