Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
5327 Lượt xem

I have a website form and I want to put html data as input  and once Submit  that html data store into backend using controller.


thank you in advanced...!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Can you please share where the Form data will store as lead or any custom model?

If you want to keep the data in any model of odoo addons.

I can give you the example of a custom form from its submit button I have created Lead.

First,  Create a new field with Html type in the crm.lead model.
  


from odoo import models, fields


class CrmLead(models.Model):
_inherit = 'crm.lead'

html_data = fields.Html('HTML DATA')

Now if you want to show in your view then you can add.


For Website Form, Here is simplest form template.
views/website_form_page_views.xml


After that, I applied Action on the form's Submit button, from where the controller will be called ...

controllers/main.py
​from odoo import http
from odoo.http import request

class WebsiteForm(http.Controller):

@http.route('/form/', type='http', auth='public', website=True)
def index_page(self, **kw):
​return request.render('website_form.form_page_view', {})


@http.route(['/form/submit'], type='http', auth="public", website=True)
def contact_form_submit(self, **post):
​request.env['crm.lead'].sudo().create({
​'contact_name': post.get('full_name'),
​'name': post.get('subject'),
​​'email_from': post.get('email'),
​​'mobile': post.get('mobilenum'),
​'html_data': post.get('html_field')

​})
​return request.render("website_form.on_success_submit", {})




Ảnh đại diện
Huỷ bỏ

Custom model 'student.addmission' :
There is field in Backend,
description = fields.Html('Description')
<field name="description" widget="html"/>

You can take input type as text it will work .

Requirement is HTML input in Frontend not a Text input...

Câu trả lời hay nhất

Hi

You can refer to the blog:  https://www.cybrosys.com/blog/how-to-create-website-form-odoo-14

Hope it helps

Ảnh đại diện
Huỷ bỏ

Not like that, Need to HTML input in Frontend. Not a text field.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 10 21
2512
0
thg 3 21
2594
0
thg 6 24
1323
1
thg 9 23
3459
1
thg 6 21
5411