Answer the question
In order to leave comments, you need to log in
How to correctly write v-model for a multidimensional array of data in a form?
I confess, I gave up, I'll try to find advice here.
I am rewriting the forms of the old site from php to vue. Work Schedule Module.
<div v-for="(city,index) in cities">
<schedule
:item="city"
@form-saved="saveData">
</schedule>
</div>
<?php foreach ($data['days'] as $key=>$day): ?>
<label> <?php echo $day['rus']; ?>
</label>
<input type="text" name="<?php echo $day['eng'];?>[open]" value="" class="time_input">---
<input type="text" name="<?php echo $day['eng'];?>[close]" value="" class="time_input"><span class="extra">примечание</span>
<input type="text" name="<?php echo $day['eng'];?>[extra]" value=""><?php endforeach; ?>
<div v-for="(day,index) in days" :key="day.engname">
<label class="block bg-academy text-white"> {{day.rus}} </label>
<input type="text" v-model="city.open[index]" class="time_input">---
<input type="text" v-model="city.close[index]" class="time_input"><span class="extra">примечание</span>
<input type="text" v-model="city.extra[index]" >
</div>
city:{
id:this.item.id,
open:[], //вот как сюда прикрутить дни недели?(
close:[],
extra:[]
},
days:[
{rus:'Понедельник',
engname:'monday',
open:'', // это я привязывал к дням через v-model="days[index].open" но сюда никак город
close:'',
extra:''
},
{rus:'Вторник',
engname:'tuesday',
open:'',
close:'',
extra:''
}
],
"id": 1,
"open": [
"12-00", //это время понедельника
"12-30" //это время вторника
],
"close": [
"21-30",
"22-00"
],
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question