Ok i just got done implementing a nested Form from
http://railscasts.com/episodes/196-nested-model-form-part-1
http://railscasts.com/episodes/197-nested-model-form-part-2
These videos are great but now i want to customize the links and make them look like buttons...
this is the link code:
<p><%= link_to_add_fields "Add Vehicle", f, :vehicles %></p>
and that actually links to a helper method:
def link_to_add_fields(name, f, association)
new_object = f.object.class.reflect_on_association(association).klass.new
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
render("shipments/partials/" + association.to_s.singularize + "_fields", :f => builder)
end
link_to_function(name, "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")")
end
how can i make this into a button
Here is a sample of a button code that i use:
<button id="add_button" class="btn btn-primary pull-right" style="margin-right: 15px;">Add Another</button>
I Have tried to add a class to the link
Tried this:
<%= button_to_remove_fields "Remove", f, :class=>"btn btn-primary pull-right" %>
Got This
wrong number of arguments (3 for 2)