我正在使用rails,而我正在尝试创建一个基本表单来发布作业。我试图添加一个单选按钮部分,用户可以在其中选择作业类型。但我面临的问题是当我通过localhost查看我的视图时,我的单选按钮没有显示:3000
这是我的表格:
<div class="card border-secondary mb-3">
<div class="card-body">
<%= form_with(model: job, local: true) do |form| %>
<% if job.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(job.errors.count, "error") %> prohibited this job from being saved:</h2>
<ul>
<% job.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="form-group">
<%= form.text_field :name, autofocus: true, class: 'form-control', placeholder: 'Job Title' %>
</div>
<div class="form-group">
<%= form.text_field :company_name, autofocus: true, class: 'form-control', placeholder: 'Company Name' %>
</div>
<div class="form-group">
<%= form.text_field :location, autofocus: true, class: 'form-control', placeholder: 'Job Location (If job is remote. Fill in with Remote)' %>
</div>
<div class="form-group">
<%= form.text_field :website, autofocus: true, class: 'form-control', placeholder: 'Company Website' %>
</div>
<div class="form-group">
<%= form.text_field :salary_range, autofocus: true, class: 'form-control', placeholder: 'Salary Range' %>
</div>
<div class="form-group">
<%= form.text_field :apply_link, autofocus: true, class: 'form-control', placeholder: 'Link Where to Apply' %>
</div>
<div class="form-group">
<%= form.hidden_field :details, class: 'form-control', id: :post_body %>
<trix-editor input="post_body", placeholder="Job discription"></trix-editor>
</div><br>
<div class="form-group">
<h4>Job type:</h4>
</div>
<div class="form-group">
<%= form.radio_button :employment_type, 'Full-time' %>
<label>
<span class="job-listing-radio-label-styles">Full Time</span> Salary position, typically 40-hour work weeks, often including benefits
</label>
</div>
<div class="form-group">
<%= form.radio_button :employment_type, 'Part-Time' %>
<label>
<span class="job-listing-radio-label-styles">Part Time</span> Hourly position, typically 35-hour work weeks or less
</label>
</div>
<div class="form-group">
<%= form.radio_button :employment_type, 'Freelance' %>
<label>
<span class="job-listing-radio-label-styles">Freelance</span> One-off projects, typically offsite with variable timeframes
</label>
</div>
<div class="form-group">
<%= form.radio_button :employment_type, 'Contract' %>
<label>
<span class="job-listing-radio-label-styles">Contract</span> One-off projects or recurring work, typically 40-hour work weeks
</label>
</div>
<div class="form-group">
<%= form.radio_button :employment_type, 'Internship' %>
<label>
<span class="job-listing-radio-label-styles">Internship</span> Paid or unpaid, full or part time, typically leading to full time employment
</label>
</div>
<hr>
<div class="form-group">
<%= form.radio_button :remote_type, 'Yes' %>
<label>
<span class="job-listing-radio-label-styles">Yes</span> This job accepts remote applications
</label>
</div>
<hr>
<div class="field-group">
<h4>Jobs Category</h4>
<%= form.select(:job_category_id, options_for_select(@job_categories), {}, class: 'custom-select') %>
</div><br>
<div class="actions">
<%= form.submit "Create New Job Posting", class: 'btn btn-success btn-block btn-lg', style: 'font-size:18px;' %>
</div>
<% end %>
</div><!-- End .card-body -->
</div><!-- End .card -->
为什么你认为他们没有出现?
非常感谢你提前! (如果您需要我删除表单的部分内容,因为问题不需要,请问:))
答案 0 :(得分:0)
也许将您的单选按钮放在标签标签内。
<div class="form-group">
<label>
<%= form.radio_button :employment_type, 'Full-time' %>
<span class="job-listing-radio-label-styles">Full Time</span> Salary position, typically 40-hour work weeks, often including benefits
</label>
</div>