Rails Simpleform with non-model inputs

前端 未结 3 1203
北海茫月
北海茫月 2020-12-15 20:35

I have a normal form using simpleform. Now I\'d like to add an input that does not have any corresponding field in the model, it will be processed by the controller. I tried

3条回答
  •  温柔的废话
    2020-12-15 21:20

    Say you wanted to use a rails form helper but still wrap it in SimpleForm goodness? You can, by calling input with a block like so:

    <%= simple_form_for @obj do |f| %>
      <%= f.input :name %>
      <%= f.input :attr do %>
        <%= text_field_tag 'attr' %>
      <% end %>
    <% end %>
    

提交回复
热议问题