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

Hi


is it possible to dynamic value in input                                     

                                        

  • t-att-value="hours"
    t-att-name="item_idx"
    id="hours"/>



i want to change the name item_idx with loop how can i get that?
i want to create or update the field from html to odoo but in for loop only one name how can i create the record ?

thanks in Advance


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

Hi,

If you need to change the name dynamically, you can set your dynamic value in the usestate of the js file., and you can call this usestate value in XML


example:

 first you need to import the usestate from odoo owl

import { useState, Component} from "@odoo/owl";

export class YourJsFile extends Component {

    setup() {

        this.name = useState({ record : [] })
       }
// Add your other js functionalities
 

}

YourJsFile.template = "your_template_name";



In your XML file you can call the usestate value to get dynamic name


t-att-value="hours"
t-att-name="name.record"
id="hours"/>


Note: The above one is just an example with your provided details, and its give an idea about how to add dynamic value on each change.


Hope it helps

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