gpt4 book ai didi

css - rails 5 : form_for select field tag with select class

转载 作者:太空宇宙 更新时间:2023-11-04 06:35:53 25 4
gpt4 key购买 nike

我目前正在尝试实现一个 select_tag,我面临的问题是每个 css 元素都有效,除了 select 选项。当我使用 f.select :home_type, [["Room", "Room"]], class: 'add-listing__input'

时,以某种方式调用引导样式表

此样式表被调用并且仅选择有效

http://localhost:3000/assets/triptip-assets.min.self-3157b4719675b23587e706840e28dab5a7506a2794b67521ade419a505a34070.css?body=1

例如,当我使用 f.text_field 时,一切正常,这个样式表被调用

http://localhost:3000/assets/style.self-6fdbeaf8dfea504b6f923ccefbf5f6a7f370c6436cf98feefac201fc92c78f83.css?body=1

编辑

这是我的表单

  <%= form_for @room do |f| %>
<div class="add-listing__form-content">
<div class="row">
<div class="col-md-6">
<label class="add-listing__label">
Home Type:
</label>
<%= f.select :home_type, [["Wohngebäude", "Wohngebäude"], ["Bürogebäude", "Bürogebäude"], ["Haus", "Haus"], ["Geschäft", "Geschäft"]], class: 'add-listing__input js-example-basic-multiple' %>
</div>
<div class="col-md-6">
<label class="add-listing__label">
Vacancy Type:
</label>
<%= f.select :vacancy_type, [["Leer", "Leer"], ["Voll", "Voll"]], class: 'add-listing__input js-example-basic-multiple' %>
</div>
</div>
<div class="row">
<div class="col-md-6">
<label class="add-listing__label">
Accomodate:
</label>
<%= f.number_field :accomodate, id: "amount", placeholder: "Für wie viele Personen?", class: "add-listing__input" %>
</div>
<div class="col-md-6">
<label class="add-listing__label">
Abrissgerüchte:
</label>
<%= f.text_field :rumors, id: "rumors", placeholder: "Abrissgerüchte?", class: "add-listing__input" %>
</div>
</div>

</div>
<% end %>

最佳答案

您应该以这种方式在选择字段中定义类:

<%= f.select(:vacancy_type, [ ... ], {}, { class: 'my_style_class' }) %>

关于css - rails 5 : form_for select field tag with select class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54235043/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com