Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
596 Vues

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


Avatar
Ignorer
Meilleure réponse

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

Avatar
Ignorer