Nice one Ryan! I recommend you all to checkout the Formtastic I18n features, they are very flexible. Not only useful for internationalization, but also usability. Peep the README. =)
Great episode. In episode 63, you discussed permalinks. If you're using some name as opposed to the id number for seo, is it possible to use formtastic and how would you do that?
Love it! I was just wondering about many to many relationships. I just have one question: what about when the list is too large to put in a list box or check boxes?
For example, I have a large database of names and phone numbers, and people can share phone numbers and also have many different phone numbers. Some sort of autocomplete and ajax addition would be interesting.
One thing I'd love to see is what if your symptoms model had been a full fledged model with additional attributes that couldn't be placed on either of the joined models? Say it had a "cured_on" attribute for when that particular problem was cured. How would you handle that?
Oh, and one other thought, what about adding a new symptom/problem that doesn't exist yet? I think you did a railscast on adding a has_many like that, but how about a many-to-many?
@DGM Formtastic there's a plugin for Formtastic that does auto complete, but IMHO, focusing on what Formtastic can't do is the wrong attitude, because you would've had to write all that code anyway. In the meantime, it's done _everything else_ for you :)
It's very easy to mix-and-match Formtastic code with custom ERB code or even make your own custom inputs (which I do all the time) to solve specific problems.
@Timóteo Formtastic is built on top of Rails' built in FormBuilder, so yes, it's very much tied to forms that have models. However, it's important to point out that it will work with *any* model or class that behaves a little bit like an ActiveRecord object.
A good example of this is AuthLogic, which has a UserSession model that isn't an ActiveRecord model, but there are plenty of people that have built login forms that work with the UserSession model and Formtastic.
@Jamie the CSS file included is, more than anything, a proof-of-concept. If you want labels on top, go for it, it's a few lines.
Eventually I'd like to offer both, because different situations will call for either a side-by-side layout or a labels-on-top layout. I'd be sceptical of any study that makes a claim that either approach is "always more usable".
I think someone's working on a formtastic-sass plugin too which does both styles.
Thanks for this! I was interested about formtastic since I first heard about it on RailsEnvy podcast a few weeks ago.
Any chance there's a third part planned to cover more has_many :through topics? Personally creating new records, auto complete and additional relationship fields have always trouble me.
But again, thanks for the awesome intro to formtastic!
When using model associations (@user.posts), @post.categories, etc), you can order the options by using the :collection parameter:
<% semantic_form_for(@user) do |f| %>
<% f.inputs do %>
# Posts is an association to users
<% f.posts, :collection => Post.all(:order => :name) %>
<% end %>
<% end %>
Hi, nice screencast!
Do you happen to know if the formtastic handles acts_as_tree plugin in association has_many :through? For example: I want to have check_boxes in the form like as tree structure..(Like categories and subcategories in eshop).
Thank you,
great tutorial from the great plugin, very nice, thanks for 2 great episode about formtastic. but i got a problem when i use paperclip, attr_accessible can't be used, because paperclip use attr_protected. whould you like to tell me about this situation ?, or give me a link about attr_protected to read ?. sorry my english is bad...
Thank you very, very much for this. I was stuck on forms for 5 hours today trying to do a multi-select on a has many through. When I couldn't figure it out I said "f it. Railscasts will have a better solution". 30 minutes later, everything works perfectly. Thank you very much!
And how do you do unit tests? If you have a partial which is one of these semantic_form_for, how the blazes do you run renderizer so that it works, hm?
Just to share with you, as I have spent plenty of hours figuring that. It is useful to have datepicker in date field. I have found a nice gist by @voldy. On http://blog.brzezinka.eu/webmaster-tips/ruby/ruby-on-rails-formtastic-jquery-ui-datepicker I show how to integrate jQuery UI datepicker with Ruby on Rails Formtastic gem.
Ok, I know this railscast was just on formatastic, but does anyone have a link/post to how you would show the lisf of problems when viewing the animal?
I can't see a way you can get the list of Problem names when all you have is the Animal ID. (in a single query.)
Basically just need the controller entry:
@animalproblems = ???? params[:id] ??
Thanks Ryan, been waiting for this!
great! exactly what I need for my current project.
thanks Ryan!
Just great, thanks Ryan! :)
Nice one Ryan! I recommend you all to checkout the Formtastic I18n features, they are very flexible. Not only useful for internationalization, but also usability. Peep the README. =)
Very nice one, Ryan. Was waiting a week for this one :) Keep up the good work
One small typo in the models/symptom.rb file: the symptom belongs to an :animal, not an ":animial" :-)
Thanks a lot Ryan for all of your screencasts.
Really good episode!! I love Monday mornings with a new Railscasts episode ;)
Hi ryan. Once again grt screencast. I love it and going to use it on me next small rails project.
Great episode. In episode 63, you discussed permalinks. If you're using some name as opposed to the id number for seo, is it possible to use formtastic and how would you do that?
Hello Ryan!
I could not find a better way to start my weeks than watching your railscasts!
Congratulations!
Luciano
Awesome as usual but do you think you could put a better spam filter on your site?
There are tons of spam posts in your comments.
Keep up the great work!
@Frederic, thanks for mentioning the typo, fixed now.
@Todd, Formtastic is not tied to the URL, so you are free to use a permalink instead of an id in there and it won't conflict.
@cbmeeks, planning to solve the spam problem soon, thanks!
And I was just looking for Formtastic tutorials when I stumbled upon this. Great as usual, Ryan!
Formtastic is great, but if you don't want your forms so tightly linked to your models, check out the Informant plugin/gem:
http://github.com/alexreisner/informant
Love it! I was just wondering about many to many relationships. I just have one question: what about when the list is too large to put in a list box or check boxes?
For example, I have a large database of names and phone numbers, and people can share phone numbers and also have many different phone numbers. Some sort of autocomplete and ajax addition would be interesting.
One thing I'd love to see is what if your symptoms model had been a full fledged model with additional attributes that couldn't be placed on either of the joined models? Say it had a "cured_on" attribute for when that particular problem was cured. How would you handle that?
How to build a form without a model linked to it? It can be done with this gem?
Oh, and one other thought, what about adding a new symptom/problem that doesn't exist yet? I think you did a railscast on adding a has_many like that, but how about a many-to-many?
Thanks Ryan. As usually your great tutorial helped me shave off those precious hours!
@DGM Formtastic there's a plugin for Formtastic that does auto complete, but IMHO, focusing on what Formtastic can't do is the wrong attitude, because you would've had to write all that code anyway. In the meantime, it's done _everything else_ for you :)
It's very easy to mix-and-match Formtastic code with custom ERB code or even make your own custom inputs (which I do all the time) to solve specific problems.
@Timóteo Formtastic is built on top of Rails' built in FormBuilder, so yes, it's very much tied to forms that have models. However, it's important to point out that it will work with *any* model or class that behaves a little bit like an ActiveRecord object.
A good example of this is AuthLogic, which has a UserSession model that isn't an ActiveRecord model, but there are plenty of people that have built login forms that work with the UserSession model and Formtastic.
@Jamie the CSS file included is, more than anything, a proof-of-concept. If you want labels on top, go for it, it's a few lines.
Eventually I'd like to offer both, because different situations will call for either a side-by-side layout or a labels-on-top layout. I'd be sceptical of any study that makes a claim that either approach is "always more usable".
I think someone's working on a formtastic-sass plugin too which does both styles.
Hi! Formtastic is very cool !
And good screencast (as usual!) :)
@justin:
Is there any helper like remote_form_for in Formtastic ?
Best regards,
Bruno
For anyone who uses haml/sass, you can get multiple form layouts (labels on top, left or right) for free using a simple sass sheet.
http://github.com/activestylus/formtastic-sass
Thanks for this! I was interested about formtastic since I first heard about it on RailsEnvy podcast a few weeks ago.
Any chance there's a third part planned to cover more has_many :through topics? Personally creating new records, auto complete and additional relationship fields have always trouble me.
But again, thanks for the awesome intro to formtastic!
There is a way to use formtastic to handle multiple models in one form like the Ryan's Classic Recipe?
Great one, as usual!
However, what if you have to deal with complex multi column forms?
Seems I'm getting spoiled ...
I am getting
The requested URL /videos/185_formtastic_part_2.mov was not found on this server.
Looking forward to watching:)
The link doesnt seem to be working...
i get a 404 message when i try to download the video
There seems to be a problem with the podcast when subscribing from itunes.
non of the files seem to be on the server:
for example it says this file can't be found on the server, and for that matter none of them can.
http://media.railscasts.com/videos/185_formtastic_part_2.m4v
Update: the latest gem would copy the formtastic.rb file to config/initializers and you don't have to create one by hand.
Nice that you added CAPTCHA to prefend spam. But now i can not help you with spam reports because of authorized error message.
Thanks for your create screencasts!
Cu
When using model associations (@user.posts), @post.categories, etc), you can order the options by using the :collection parameter:
<% semantic_form_for(@user) do |f| %>
<% f.inputs do %>
# Posts is an association to users
<% f.posts, :collection => Post.all(:order => :name) %>
<% end %>
<% end %>
Is there any explanation as to why we need to use 'attr_accessible' on all attributes in the model? Seems like a lot of work...
Any ideas how i get the code from the complex forms railscasts to work with formtastic ?
How would that project example look in formtastic ?
<% for task in @project.tasks %>
<% fields_for "project[task_attributes][]", task do |task_form| %>
<p>
Task: <%= task_form.text_field :name %>
</p>
<% end %>
<% end %>
great stuff! so, what about dynamic select boxes?? still by hand?
Hi, nice screencast!
Do you happen to know if the formtastic handles acts_as_tree plugin in association has_many :through? For example: I want to have check_boxes in the form like as tree structure..(Like categories and subcategories in eshop).
Thank you,
H.
Trying to recreate this with HAML but can't get it to work can you give me the basic form?
great tutorial from the great plugin, very nice, thanks for 2 great episode about formtastic. but i got a problem when i use paperclip, attr_accessible can't be used, because paperclip use attr_protected. whould you like to tell me about this situation ?, or give me a link about attr_protected to read ?. sorry my english is bad...
Thank you very, very much for this. I was stuck on forms for 5 hours today trying to do a multi-select on a has many through. When I couldn't figure it out I said "f it. Railscasts will have a better solution". 30 minutes later, everything works perfectly. Thank you very much!
Robert
Thanks for this one, Ryan!
A third part would be nice, like in complex forms 3, where you add/remove checkboxes dynamically ;-)
@carl
See the formtastic rdoc, there's an example for nested forms ;-)
Thanks for this Ryan and all the other great casts you have done.
Have you managed to get this excellent gem to work with Rails3, I cant seem to get rid of the undefined method semantic_form_for error
And how do you do unit tests? If you have a partial which is one of these semantic_form_for, how the blazes do you run renderizer so that it works, hm?
No unit testing examples, no TDD. Pity.
Just to share with you, as I have spent plenty of hours figuring that. It is useful to have datepicker in date field. I have found a nice gist by @voldy. On http://blog.brzezinka.eu/webmaster-tips/ruby/ruby-on-rails-formtastic-jquery-ui-datepicker I show how to integrate jQuery UI datepicker with Ruby on Rails Formtastic gem.
Ok, I know this railscast was just on formatastic, but does anyone have a link/post to how you would show the lisf of problems when viewing the animal?
I can't see a way you can get the list of Problem names when all you have is the Animal ID. (in a single query.)
Basically just need the controller entry:
@animalproblems = ???? params[:id] ??