跳至内容
菜单
此问题已终结
1 回复
712 查看

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


形象
丢弃
最佳答案

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

形象
丢弃