Here is the case :
the HTML:
<form x-data="{cmpData:[]}" x-init=" cmpData = await cmpForm('myID')">
<input x-model="cmpData.myref" name="myref" type="text">
the JS:
async function cmpForm(CMP) {
let myData=[]
myData= await DB.myDB.get(CMP);
if(!myData){
myData= {
myref: CMP,
somethingelse:'',
}
}
return {
cmpData:myData,
}
}
=> no error but the input is not working = no x model
but if i
<input x-model="cmpData.cmpData.myref" name="myref" type="text">
the input work , but it triggers an error
Uncaught (in promise) TypeError: cmpData.cmpData is undefined
please, let me know what i miss !
i just would like : form is initialized with async function
thank you