【问题标题】:fill form fields from relationship model in vform vue laravel从 vform vue laravel 中的关系模型填充表单字段
【发布时间】:2020-04-13 05:18:15
【问题描述】:

我的表单使用vue vform,这里是编辑模态的功能,

   editModal(household){
        this.form.reset();
        $('#addNewHouseholdModal').modal('show');
        this.form.fill(household); // this line fills the form with data to be edited
    }

但我有数据存储在另一个表中的表单字段。我已收到数据,但无法弄清楚如何在表单中显示它们。请帮帮我。以下是我在上面的表格中传递的家庭数据。

id: 1
address_details_id: 14
ward: 2
house_no: "2"
family_no: "45"
geolocation: "{"latitude":"1.1","longitude":"1.1"}"
address_details: Object
  id: 14
  province: "23"
  name: "Strret"

除了作为对象的地址详细信息之外,所有详细信息都填写在表单中,如何从表单中的地址详细信息中填写姓名?谢谢你。我们将不胜感激。

【问题讨论】:

    标签: laravel vue.js vuejs2


    【解决方案1】:

    我认为您需要在打开模式之前先传递数据。

    editModal(data) {
      isEditting = true
      this.form.family_no = data.family_no
      this.form.house_no = data.house_no
      this.form.address = data.address
      $('#addNewHouseholdModal').modal('show');
    }
    

    然后你的表格一定是这样的

    <modal>
      <input type="text" v-model="form.family_no" />
      <input type="text" v-model="form.house_no" />
      <input type="text" v-model="form.address" />
    <modal>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-27
      • 2018-07-10
      • 2016-06-11
      • 2019-10-21
      • 2015-05-13
      • 1970-01-01
      相关资源
      最近更新 更多