php - laravel livewire 中的数组编辑
问题描述
所以我的模型中有一个 $information ,其中包含类似 JSON
{
"key": "value",
"key1: "value1"
}
我想要做的是制作一个能够添加和编辑这个模型的crud,值得注意的是 $information 是动态的并且可能有很多行,我使用 eloquent::json 将此数据存储在数据库中并使用json_decode($信息,1)。我需要的是一个用于编辑和创建表单的 HTML 结构。(实际上我有这样的东西:
<template x-for="(field, index) in fields" :key="index">
<tr>
<td x-text="index + 1"></td>
<td><input wire:model="information" style="width: 190px" type="text" name="txt1[]"></td>
<td><input wire:model="information" style="width: 190px" type="text" name="txt2[]"></td>
<td>
<button type="button" class="btn btn-danger btn-small"
@click="removeField(index)">×
</button>
</td>
</tr>
</template>
</tbody>
<tfoot>
<tr>
<td colspan="4" class="text-right">
<button type="button" class="btn btn-info"
@click="addNewField()">+ Add Row
</button>
</td>
</tr>
</tfoot>
但它在从模型加载数据时遇到问题,也无法保存任何内容。谢谢你的帮助~
解决方案
推荐阅读
- python - 创建嵌套字典,为每个键提供值范围
- amazon-redshift - 为什么我得到一个“列
关系的 在 dbt 中运行模型但在 SQL 客户端中运行时不存在”错误? - reactjs - reduce 函数不断更新挂载值
- javascript - Javascript event.stopPropogation 仍在触发按钮的子元素
- html - 表格的宽度需要与表格的其余部分相同
- sql - PHPmyadmin 中的 SQL 查询无法区分表情符号
- c# - 从 EFCore 延迟加载的上下文中删除导航集合实体 - 导航集合不会立即更新
- python-3.x - 如何在centOS 8上安装不同版本的python?
- javascript - 如何使模态出现 onClick 变化?
- c - 输入的微小变化会使程序发疯