SimpleForm without for (non model form)

前端 未结 5 1934
情书的邮戳
情书的邮戳 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 could also pass a :symbol instead of @object as argument for simple_form_for.

    <%= simple_form_for :email, :url => '/post_email' do |f| %>
      <%= f.input :subject, :as => :string %>
    <% end %>
    

    Which would output:

    
    

    Please be aware of following draw-backs:

    • You won't be able to take advantage of automatic model validation
    • Need to explicitly define :url and the type of each input

提交回复
热议问题