Sha256: bac74f2904fa3663cbe82682a8dadae2a3b616b8c164419e1ff24543aeae6175
Contents?: true
Size: 819 Bytes
Versions: 18
Compression:
Stored size: 819 Bytes
Contents
module DynamicScaffold module Form module Item class Cocoon < Base attr_reader :form def initialize(config, type, name, options = {}) super @options = options @form = FormBuilder.new(config) yield(@form) end def extract_parameters(permitting) permitting << { "#{@name}_attributes": [*@form.items.map(&:name).push(:_destroy)] } end def filter(&block) @filter = block self end def add_text @options[:add_text] || "Add #{proxy_field.label}" end def build_children(record) children = record.public_send(name).to_a children = @filter.call(children) if @filter.present? children end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems