Hi,
Can someone help me with the following questions. I am trying to create
a link_to_remote link named add. Whenever I click add, a new label and
text field will be populated.
Example:
(This is already there)
Book 1 text_field add(this is the link)
…when add is clicked…
…the following is populated…
Book 2 text_field
My question is how do I increment the number? How do I submit the
various fields, populated and the one that is already there, that are in
the form ? I read some where that it has to do with the id of the field.
This is my controller
def book
@book = Book.new
end
def save_book
@book = Book.new(params[:book])
if @book.save
redirect_to :action => ‘some_page’
else
render :action=> ‘book’
end
end
def add_book
@count = 1
render(:partial => ‘additional_book’)
end
This is my view
…_additional_book.rhtml…
…book.rhtml…
Book 0 | <%= n.text_field :book %> <%= link_to_remote( "add", :update => "abc", :url =>{ :action => :add_book }, :position => "bottom", :success => "@count ++") %> |
Thanks