Skip to Content
Menu
This question has been flagged
1 Reply
9050 Views

I want to use HTML Rich Text field on Website form. We can use widget="html" on odoo forms field but how can we use this widget on website form of odoo v12? Thanks in advance.

Avatar
Discard
Best Answer

Actually you know it and already used it :)
This is an odoo website forum(website page) and I am currently writing in a rich text editor. in the backend, this is Html field.

Ok so take fields.HTML in backend instead of Text so the server will do all the HTML sanitization work for you and the user could not inject any unsafe code.

Create a custom route for post and define HTML form with your field
https://github.com/odoo/odoo/blob/12.0/addons/website_forum/views/website_forum.xml#L558 (here content is html field)

and last, initialize it with summernote editor on this field (here it's done by load_editor class
https://github.com/odoo/odoo/blob/12.0/addons/website_forum/views/website_forum.xml#L558

 

Avatar
Discard
Author

I added class load_editor in my html field. But it seems that its not just adding class, Some JS code is also required to render HTML editor. I tried following JS in my module but no luck.

https://github.com/odoo/odoo/blob/a7d24cabafe1a9c71f9dbdb7cf3f129006250951/addons/website_forum/static/src/js/website_forum.js#L395

(summernote initialized here.)