Help us understand the problem. What is going on with this article?

Rails 5 Bootstrap でフォームを作るときのhidden_field_tagの書き方

More than 1 year has passed since last update.



Ruby version: RUBY VERSION: 2.6.3
Rails version: Rails


  <%= form_for( do |f| %>
    <div class="form-group">
      <%= hidden_field_tag :film_id, %>

    <div class="form-group">
      <%= f.label :rate, 'rate' %>
      <%= f.number_field :rate, class: 'form-control' %>
    <div class="form-group">
      <%= f.label :comment, 'comment' %>
      <%= f.text_field :comment, class: 'form-control' %>
    <%= f.submit 'watched', class: 'btn btn-primary btn-block' %>
  <% end %>

ポイントは hidden_field_tagもclass=form-groupのdivで囲むことです.

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away