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

Hello!

I am trying to develop a dynamic website form. There is a selection / drop down field "type" which controls the visibility of certain other fields. 

For the backend this was easy:

 <group name="zba" string="ZBA" attrs="{'invisible':[('type', '!=','zba')]}">
                        <field name="zba_1"/>
                        <field name="zba_2"/>
                        <field name="zba_3"/>
 </group>


Unfortunately I haven't found instructions on how to archive this for the Odoo website. I tried to add


attrs="{'invisible':[('type','!=','zba')]}">


to <div>, but it doesn't work:


<div name="email_from_container" t-attf-class="form-group #{error and 'email' in error and 'has-error' or ''}" attrs="{'invisible':[('type','!=','zba')]}">

 

Is there any solution to this? Thank you.

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

It may be achieved through the controller. look at website_sale for reference

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

Hello PeterN,

I think, you need to develop a javascript if you want to hide/display a field dynamically on website.

for example:

``` 
$('select').change(function()){
if ($(this).val() == 'xxx') {
$('input').hide();
}
});
```
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 24
7447
5
thg 8 25
9766
2
thg 7 25
939
4
thg 6 25
1053
1
thg 6 25
1350