Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

HTMLEditorField


Go to End


4 Posts   2452 Views

Avatar
PGiessler

Community Member, 47 Posts

21 October 2009 at 4:45am

Hi,

I'm writing a module to extend SilverStripe. In the module I create serveral form fields (TextField, TextareaField and so on). Furthemore I can save everything into my MySQL database. But there is a problem: I can't save the modified content of an HTMLEditorField. If I edit manually the HTML content in the database, it will displayed without any problems. But in the CMS Backend no chance, the content will ignored. The database array field is set to 'HTMLText'. So this isn't the problem.

My function getEditForm($id) return form. The AJAX request works! So I looked into the requested object and there is no value of the form field with the HTML text. If I changed the HTMLEditorField into a TextareaField everything works and the content will updated in the database. So my question is why does the requested object doesn't have the value of a form field of type HTMLEditorField.

Best regards,

Pascal

Avatar
Willr

Forum Moderator, 5523 Posts

21 October 2009 at 12:27pm

Is your database field a 'HTMLText' field?

Avatar
PGiessler

Community Member, 47 Posts

21 October 2009 at 6:49pm

Yes, my database field is a HTMLText. If I don't set this type, I will get a error in the function saveInto() on the class HTMLEditorField
So this isn't the reason for my problem. I hope you have another solution.

Avatar
Ingo

Forum Moderator, 801 Posts

2 November 2009 at 8:32am

> But there is a problem: I can't save the modified content of an HTMLEditorField

So no content is saved at all? Or saved as escaped HTML instead of raw? Does the data get submitted with the POST ajax request? (you can check this with getfirebug.com). Keep in mind that in case you're using some custom TinyMCE or otherWYSIWYG formfield thats not a plain HTMLEditorField, you'll likely need to tell the editor via JavaScript to extract the HTML *before* saving.