Module: AddRemoveLinksHelper

Defined in:
lib/generators/skizmo/form/templates/helper.rb

Instance Method Summary collapse

Instance Method Details



6
7
8
9
10
11
12
# File 'lib/generators/skizmo/form/templates/helper.rb', line 6

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(association.to_s.singularize + "_fields", :f => builder)
  end
  link_to_function(name, "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")")
end


2
3
4
# File 'lib/generators/skizmo/form/templates/helper.rb', line 2

def link_to_remove_fields(name, f)
  f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)")
end