#234 SimpleForm (revised)
Easily generate complex forms with SimpleForm. Here I show how to convert bulky markup into a concise list of fields, customize it by passing options, and add error handling.
- Download:
- source code
- mp4
- m4v
- webm
- ogv
How does fields_for work for simple form?
I am using twitter_bootstrap_form_for in my current project, and it has some issues, this is why I am considering moving to simple_form_for, and this is why I am a bit courious about the advantages of simple_form over twitter_bootstrap_form_for. Thanks!
Does simple form work for dynamic select menus?
http://railscasts.com/episodes/88-dynamic-select-menus-revised
Please if someone has an example, would be very helpful.
You can pass a block to
f.input
orf.association
call and use rails form helpers there like this:Doing so, you get simple_form's, label, hint and other stuff, but overwrite only the actual input to the one you need.
I cannot post all my code here since even with simple_form, my form is quite large, but here is the gist:
Then you use the following coffeescript markup in app/assets/javascripts/contracts.js.coffee file:
So there is nothing that Simple form specific here really. It is the code from aforementioned revised screencast on dynamic menus tweaked for my own simple form.
Hey Thanks Ryan,
Now the stage is all set for a set of Pro (Advanced) screencasts for leveraging SimpleForms with Twitter Bootstrap :)
Keep up the great work!
+1 - this would be very useful
+1
how woud someone use simple form to generate something like below. As you can see the input is wrapped with a div.
You can have SimpleForm to generate those wrappers by default, so you won't clutter your views with styles.
The docs are really easy to read, well written.
https://github.com/plataformatec/simple_form
How would SimpleForm work with a form that isn't associated with an object? For example, a login form.
It is not meant to be used for such forms (e.g. form_tag based forms which do not have an underlying model).
it is meant to be used for the forms which are connected to an underlying data table which happens to be majority of forms for a CRUD based Rails application.
You can simply assign the form to a symbol or string
or
This provides for your resource object, so the parsed params in your controller will look like:
Cheers mate. It was really helpful ;)
I m very new to ruby on rails, so can you help me.
I m getting the following error
this is my new form
this is my user controller
Does anyone have a good css snippet for vertical-aligning the label in the middle of a text area?
how does one output a field as a label? I have a user id. A user cannot edit the user id. One way is to set it to disabled, but that doesn't look so nice and gives the impression that it is an editable field.
Thanks Ryan!
What about a revised version of Formtastic? This will be great.
Have a nice weekend.
Is there any way to make simple_form work nice with ancestry?
I have alerts which have many categories, and categories are nested with ancestry.
Currently I'm using:
<%= f.association :category, :collection => Category.sort_by_ancestry(@organization.categories), :as => :check_boxes %>
But I would like to have categories nested visually.
Is there a way to get "No File Chosen" to stay hidden, until the user uploads a file? I'm using Simple_Form and Paperclip in my app. Tried some examples on StackOverflow but none them worked out.
Famous Monster (L)= Max lv 100; Evo lv 25; require 2.116.220 food to get to degree 100. Its provided really in-depth info of all monsters as well as the best ways to breed every one of them