这个HTML编写的表单是否可以像脚手架生成的Ruby表单一样编写?

时间:2014-11-03 01:58:46

标签: html ruby-on-rails ruby forms twitter-bootstrap

因为这是用Bootstrap编写的,是否会阻止我在Ruby中编写它来替换通过生成脚手架生成的表单?

我编码的HTML / Bootstrap表格

   <form class="form-horizontal">
        <div class="control-group">
            <label class="control-label" for="inputEmail">Email:</label>
            <div class="controls">
            <input type="text" id="inputEmail" placeholder="Email">
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="inputTwitter">Twitter User</label>
            <div class="controls">
            <input type="text" id="inputTwitter" placeholder="Twitter User">
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="inputSession">Primary Trading Session</label>
            <div class="controls">
                <select name="selTradingSession">
                    <option value"0">U.S. Session</option>
                    <option value"1">European Session</option>
                    <option value"2">Asian Session</option>
                </select>
            </div>
            <br>
            <div class="text-center"><button type="submit" class="btn">Send</button></div>
        </div>
        <p><small class="text-muted">*We will not give out your email or twitter handle.   </small></p>
    </form>

脚手架生成表格

<%= form_for(@softrun) do |f| %>
  <% if @softrun.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@softrun.errors.count, "error") %> prohibited this softrun from being saved:</h2>

      <ul>
      <% @softrun.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :soft_email %><br>
    <%= f.text_field :soft_email %>
  </div>
  <div class="field">
    <%= f.label :soft_twitter %><br>
    <%= f.text_field :soft_twitter %>
  </div>
  <div class="field">
    <%= f.label :prim_session %><br>
    <%= f.text_field :prim_session %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

1 个答案:

答案 0 :(得分:1)

脚手架只是通用的样板。该模板是通用引导程序。你必须将两者合并在一起。

当我进行模板合并时,我通常将引导程序中的公共元素拉到局部,然后以rails脚手架形式呈现它们。