module Formnestic::FormBuilder::ListFormBuilder
Public Instance Methods
formnestic_list_semantic_fields_for( record_or_name_or_array, *args, &block )
click to toggle source
# File lib/formnestic/form_builder/list_form_builder.rb, line 7 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] ) if resolve_row_addable(options[:row_addable]) contents.push( formnestic_add_new_record_button_row_for_list_form( record_or_name_or_array, *args, &block ) ) end 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
resolve_row_addable(row_addable)
click to toggle source
# File lib/formnestic/form_builder/list_form_builder.rb, line 63 def resolve_row_addable(row_addable) return row_addable if [true, false].index(row_addable) return true if row_addable.nil? return row_addable.call if row_addable.is_a?(Proc) true end