Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpleForm without for (non model form)

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

https://github.com/plataformatec/simple_form

like image 273
Edward Ford Avatar asked Mar 03 '11 13:03

Edward Ford


1 Answers

You can use :symbol as the first argument.

<%= simple_form_for :user, url: users_path do |f| %>   <%= f.input :name, as: :string %>   ... <% end %> 

It will output something like this:

<form novalidate="novalidate" class="simple_form user" action="/users" accept-charset="UTF-8" method="post">   ...   <div class="input string required user_name">     <label class="string required" for="user_name">       <abbr title="required">*</abbr> Name     </label>     <input class="string required" type="text" name="user[name]" id="user_name" />   </div>   ... </form> 
like image 108
htanata Avatar answered Sep 19 '22 11:09

htanata