php - Codeigniter 4 - 如何使用 form_checkbox?
问题描述
我不知道如何在 ci4 中使用 form_checkbox。我正在尝试为帖子制作更新表格。首先,页面读取数据并填充表单。发布后,如果有任何变化,它应该更新数据库。我在设置 bootstrap 4 切换时遇到问题(https://gitbrent.github.io/bootstrap4-toggle/)
这是我的代码;
<label for="post_is_published">
<input type="hidden" name="post_is_published" value="0" data-off="Not Published">
<input
data-toggle="toggle"
type="checkbox"
name="post_is_published"
id="post_is_published"
value="1"
<?php if(old('post_is_published', $post->post_is_published)): ?>
data-toggle='toggle' data-on="Published"
<?php endif; ?>
>
Is Published?
</label>
如果为 1,则发布,如果为 0,则不发布。
解决方案
推荐阅读
- python - fobi 表单的网址是什么?以及如何将其嵌入到另一个模板中?
- amazon-web-services - 在 Deploy 上找不到 Buildspec 文件?
- python - 如何在 python 中将 8 个 32 十六进制数据列表加入单个 256 位数字列表?
- sql - 使用另一个跳过空值更新一个表的方法
- android - 如何设置一个或两个数据相似但用于不同目的的表
- javascript - 通过 fetch api 发送带有 ajax 请求的 cookie
- swiftui - SwiftUI 按钮仅点击文本部分
- asp.net-web-api - Web API,使用 Azure AD 进行身份验证
- c# - 使用 SqlCommand 存储过程到 Object 对象为空
- java - 将mongo十进制数转换为java BigDecimal