Instead of writting custom tags, you could write a custom form builder with methods for those fields -> http://onrails.org/articles/2008/06/13/advanced-rails-studio-custom-form-builder - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)
On Mon, Jan 26, 2009 at 7:25 AM, Shilo Ayalon <rails-mailing-l...@andreas-s.net> wrote: > > Hi, > > I find that I have the following appear a lot inside forms in my app: > > <% names = SomeAssociatedModel.find(:all, :order => 'name') > <%= f.collection_select :some_id, names, :id, :name %> > > Which is basically a select list of names vs. id. I use it when I relate > between associated models (with has_many and belongs_to). I would like > to write a custom tag for it, something like: > > <%= f.names_select :some_id, object_to_select_from %> or similar. This > way, I could use it when, say, editing cities that are associated with > states: > > <%= f.names_select :state_id, State %> > > I also have a select that's yes/no: > > <%= f.select :is_active, [['yes',true],['no',false]] %> > > that I'd like to turn to: > > <%= f.yes_no_select :is_active %> > > Any pointers will surely help - thanks. > -- > Posted via http://www.ruby-forum.com/. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---