【发布时间】:2021-11-01 10:08:54
【问题描述】:
你好, 以下代码段旨在询问用户是否想成为我们博客网站的客座作者,但是单选切换始终返回零值。 MYSQL 列的类型为 tinyint(1)。
<!-- Author? -->
<div class="author" style="text-align: center; margin-bottom: 1rem;">
<h3><strong>Are you interested in earning money blogging for us?</strong></h3>
<div class="form-check-inline">
<input class="form-check-input" name="is_author" type="radio" value="true" id="is_author1" style="top: 0.1rem; width: 1.50rem; height: 1.50rem;">
<h4 class="form-check-label" for="is_author">Yes, please.</h4>
</div>
<div class="form-check-inline">
<input class="form-check-input" name="is_author" type="radio" value="false" id="is_author0" style="top: 0.1rem; width: 1.50rem; height: 1.50rem;">
<h4 class="form-check-label" for="is_author">No, thank you.</h4>
</div>
</div>
下面是控制器中“is_author”的引用方式:
protected function validator(array $data)
{
return Validator::make($data, [
'is_author' => ['required', 'boolean'],
]);
}
protected function create(array $data)
{
return User::create([
'is_author' => $data['is_author'],
]);
}
提前致谢
【问题讨论】:
标签: php html mysql laravel twitter-bootstrap