Sha256: 810c5de44179aeb396131a6f055a4443f9384a77d7b4ae177df76416dfbe49f5

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

module Formnestic
  module FormBuilder
    module ListFormBuilder
      include Formnestic::FormBuilder::BaseBuilder
      def formnestic_list_semantic_fields_for(record_or_name_or_array, *args, &block)
        options = args.dup.extract_options!

        formnestic_add_rows_counter_related_attributes
        existing_rows = formtastic_semantic_fields_for(record_or_name_or_array, *args, &block)
        contents = [template.content_tag(:div, existing_rows, class: 'formnestic-list-entries-container')]

        options[:min_entry] ||= -1
        options[:max_entry] ||= -1

        options[:min_entry_alert_message] = formnestic_min_entry_alert_message(record_or_name_or_array, options[:min_entry])
        contents.push(formnestic_add_new_record_button_row_for_list_form(record_or_name_or_array, *args, &block)) if options[:row_addable]
        options[:class] = [options[:class], 'formnestic-nested-model-container'].compact.join

        template.content_tag(:div,
                             contents.join.html_safe,
                             options.except(:builder, :parent, :name, :parent_builder, :display_type, :row_removable, :new_record_link_label, :child_index))
      end

      def formnestic_add_new_record_button_row_for_list_form(record_or_name_or_array, *args, &block)
        template.content_tag(:div, formnestic_link_to_add_fields_with_content(record_or_name_or_array, *args, &block), class: 'formnestic-list-new-entry-link-container')
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
formnestic-1.0.11 lib/formnestic/form_builder/list_form_builder.rb
formnestic-1.0.10 lib/formnestic/form_builder/list_form_builder.rb
formnestic-1.0.9 lib/formnestic/form_builder/list_form_builder.rb
formnestic-1.0.8 lib/formnestic/form_builder/list_form_builder.rb
formnestic-1.0.7 lib/formnestic/form_builder/list_form_builder.rb
formnestic-1.0.6 lib/formnestic/form_builder/list_form_builder.rb