SimpleForm without for (non model form)

前端 未结 5 1923
情书的邮戳
情书的邮戳 2020-11-30 21:57

Is it possible to use Simple Form (by: Plataformatec) without a model?

https://github.com/plataformatec/simple_form

5条回答
  •  無奈伤痛
    2020-11-30 22:53

    You can also use fields outside the model within a form model, with simple_fields_for like this:

    <%= simple_form_for @user do |f| %>
      <%= f.input :name %>
    
      <%= simple_fields_for :no_model_fields do |n| %>
        <%= n.input :other_field %>
      <% end %>
    <% end %>
    

    This is simple and practical solution, because you can create different kind of fields from different models or without using models

提交回复
热议问题