如何解决带模型属性绑定的Livewire简单下拉菜单和“保存”按钮
我认为我有
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\Post;
class PostPublicToggle extends Component
{
public Post $post;
protected $rules = [
'post.is_public' => 'boolean'
];
public function render()
{
return view('livewire.post-public-toggle');
}
public function save()
{
$this->validate();
$this->post->save();
}
}
在组件中:
.defer
首先,我希望它能在没有提交按钮的情况下工作(选择更改后自动提交)。但这没有用,所以这就是为什么我添加了post.is_public = null
和一个提交按钮的原因。
现在,当我按下“提交”时,我可以在XHR请求中看到jq --slurpfile config1 config1.json '.config += $config1' config.json
,但我不明白为什么。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。