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

I'm trying to make a button in the website but the button is inside a form and try tu submit the form even it has not the "type='submit'" 
Well I take it out of the form but it does nothing, here my code:




    




In the model i got an logger for see if its working but nothing else






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

Hello Sven Seemann Salazar,

I hope you are doing well.

You can check this code.

Please find code in comment.

I hope this helps.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

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

First you need to define the button inside a <form> tag in the website template XML

<form action="/Your_controller_name" method="post">
<button type="submit" class="btn">Call a controller</button>
</form>

- Clicking the button submits the form and calls the controller in python

class (Your ClassName)(http.Controller):

@http.route(['/Your_controller_name'], type='http', auth='public', website=True)
def my_controller_method(self, redirect=None, **post):
# Put your code here,

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

Hi,

Please ensure that your form has an attribute called ‘action’ and you have provided a proper(existing) controller as a value for it.

Also make sure that your form and button follows the structure that is mentioned below

Example

<form action=’/your/controller’ method=’post’>


      //your inputs


     ...........


      <button type=’submit’> Submit </button>


 </form>


Regards

Ảnh đại diện
Huỷ bỏ
Tác giả

Yes I have this, but I want another button that DOES NOT submit the form, it performs another action

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 24
2905
4
thg 3 24
4946
1
thg 3 24
1572
1
thg 2 24
1417
1
thg 9 22
3688