I am creating a data entry form that allows a user to fill in multiple rows and save them all at once. In my controller, I create an array of "person" objects and pass it to the page. On the page, I have a text field like so: <%= text_field "person", "name", "index" => 1 %> Note the "index" attribute, which sets the name and id correctly. I would like to do the same with a collection_select, but can''t seem to get it to work. Does anyone know if there is an elegant way to set the "index" attribute of a collection_select? Something like: <%= collection_select(''person'', ''type'', @person_types, ''id'', ''name'', ''index'' => 1) %> Here''s the documentation for the text_field that describes the index property http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M00038 9 Thanks, Jeff Dean www.jefdean.com <http://www.jefdean.com/> jeff@jefdean.com 917 414 7801 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060622/cbaed2b9/attachment.html
Mark Reginald James
2006-Jun-22 06:26 UTC
[Rails] Re: Setting an index on a collection_select
Jeff Dean wrote:> Note the ?index? attribute, which sets the name and id correctly. I > would like to do the same with a collection_select, but can?t seem to > get it to work. Does anyone know if there is an elegant way to set the > ?index? attribute of a collection_select? Something like: > > <%= collection_select(''person'', ''type'', *@person_types*, ''id'', ''name'', > ''index'' => 1) %>For select and collection_select index goes with the html_options parameter rather than the options parameter. So you want something like: collection_select :person, :type, @person_types, :id, :name, {}, :index => 1 -- We develop, watch us RoR, in numbers too big to ignore.
I would like to incorporate Typo into an existing app (or vice versa). What is the best way to do this? Ideally, I would love to put it in vendor-plugins and run it like an engine - is this possible? If so, are there any tutorials? Jeff Dean