[IMP] website_form: converts text data into html data
In website forms, for both html/text type of fields, we provide simple textarea to users for entering the data. And, we store the data as it is for both of them. But with this change, we're trying to convert plain text (entered by user in the online form for html type of fields) into to html, so for example it can replace \n with <br> and properly formatted data can be saved. Task id: 2499504 X-original-commit: b8d5b61333b0e8570ea2eb0535e37a0025514812
This commit is contained in:
committed by
Thibault Delavallée
parent
586ae4bcc4
commit
a7437aac10
@@ -3,16 +3,13 @@
|
||||
|
||||
import base64
|
||||
import json
|
||||
import pytz
|
||||
|
||||
from datetime import datetime
|
||||
from psycopg2 import IntegrityError
|
||||
from werkzeug.exceptions import BadRequest
|
||||
|
||||
from odoo import http, SUPERUSER_ID, _
|
||||
from odoo.http import request
|
||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
||||
from odoo.tools.translate import _
|
||||
from odoo.tools import plaintext2html
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
from odoo.addons.base.models.ir_qweb_fields import nl2br
|
||||
|
||||
@@ -100,6 +97,9 @@ class WebsiteForm(http.Controller):
|
||||
def floating(self, field_label, field_input):
|
||||
return float(field_input)
|
||||
|
||||
def html(self, field_label, field_input):
|
||||
return plaintext2html(field_input)
|
||||
|
||||
def boolean(self, field_label, field_input):
|
||||
return bool(field_input)
|
||||
|
||||
@@ -115,7 +115,7 @@ class WebsiteForm(http.Controller):
|
||||
_input_filters = {
|
||||
'char': identity,
|
||||
'text': identity,
|
||||
'html': identity,
|
||||
'html': html,
|
||||
'date': identity,
|
||||
'datetime': identity,
|
||||
'many2one': integer,
|
||||
|
||||
Reference in New Issue
Block a user