复选框不会显示在网页上但没有错误

问题描述 投票:-3回答:1

我没有收到任何错误,但复选框不会显示在页面上? enter image description here

我想设置我的复选框样式,但如果没有显示我就不能。如果有人可以查看我的代码,看看为什么它没有显示它将不胜感激!谢谢

                        <div class="row justify-content-center">
                            <div class="col-12 col-xl-11">
                                <div class="row form-group">
                                    <div class="col-md-4">
                                        <%= f.check_box :is_hungry %> Hungry
                                    </div>
                                    <div class="col-md-4">
                                        <%= f.check_box :uplifted %> Uplifted
                                    </div>

                                    <div class="col-md-4">
                                        <%= f.check_box :is_euphoric %> Euphoric
                                    </div>
                                </div>
                                <div class="row form-group">
                                    <div class="col-md-4">
                                        <%= f.check_box :is_energetic %> Energetic
                                    </div>

                                    <div class="col-md-4">
                                        <%= f.check_box :is_creative %> Creative
                                    </div>

                                    <div class="col-md-4">
                                        <%= f.check_box :is_focused %> Focused
                                    </div>
                                </div>
                                <div class="row form-group">
                                    <div class="col-md-4">
                                        <%= f.check_box :is_relaxed %> Relaxed
                                    </div>
                                    <div class="col-md-4">
                                        <%= f.check_box :is_happy %> Happy
                                    </div>

                                    <div class="col-md-4">
                                        <%= f.check_box :is_balanced %> Balanced
                                    </div>
                                </div>
                                <div class="row form-group">
                                    <div class="col-md-4">
                                        <%= f.check_box :is_painrelief %> Pain Relief
                                    </div>
                                    <div class="col-md-4">
                                        <%= f.check_box :is_sleepy %> Sleepy
                                    </div>
                                </div>
                            </div>
                        </div>
ruby-on-rails ruby
1个回答
0
投票

我认为问题是你使用的是f.check_box,但你没有表格标签。如果你不想要它,你应该使用这样的复选框:

<%= check_box_tag 'Hungry', 'yes', id: 'is_hungry' %> Hungry

文档:https://apidock.com/rails/ActionView/Helpers/FormTagHelper/check_box_tag

© www.soinside.com 2019 - 2024. All rights reserved.