Sha256: 8614d8b2c9171a88e85786a2f2a8fa16da944da07cc086e0bd0285cb4abf2eee

Contents?: true

Size: 721 Bytes

Versions: 3

Compression:

Stored size: 721 Bytes

Contents

module Components
  module Lolita
    module ConfigurationComponent
      def link_to_remove_fields(name, f)
        f.hidden_field(:_destroy) + link_to(name, "#", onclick: "remove_fields(this)")
      end

      def link_to_add_fields(name, f, nested_form)
        new_object = nested_form.klass.new
        fields_content = ""
        f.fields_for(nested_form.name, new_object, child_index: "new_#{nested_form.name}") do |builder|
          self.current_form(builder) do
            fields_content = render_component(nested_form, :"fields")
          end
        end
        link_to(name, "#", onclick: "add_fields(this, \"#{nested_form.name}\", \"#{escape_javascript(fields_content)}\")")
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lolita-4.0.2 app/helpers/components/lolita/configuration_component.rb
lolita-4.0.1 app/helpers/components/lolita/configuration_component.rb
lolita-4.0.0 app/helpers/components/lolita/configuration_component.rb