Created
July 22, 2011 16:41
-
-
Save acorcutt/1099813 to your computer and use it in GitHub Desktop.
Post array of text_field's in rails as array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%-# items is an array on object e.g. object.items = [1,2,3], we want to display as list of fields, and post back as an array - note the backwards ][ which makes is do this! -%> | |
<% @object.items.each do |i| %> | |
<%=f.text_field "items][",:value=>i,:id=>"item-#{SecureRandom.uuid}" %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice. The only issue is if you also have a label for each corresponding text field, clicking on any label selects the first text field.
Do you know a way to correct this? It may be impossible due to the naming conventions I suppose