Store the wrapper API attributes in the leaves
This commit is contained in:
parent
95da39311f
commit
dda200645a
|
@ -47,9 +47,9 @@ module SimpleForm
|
||||||
|
|
||||||
def use(name, options=nil, &block)
|
def use(name, options=nil, &block)
|
||||||
if options && wrapper = options[:wrap_with]
|
if options && wrapper = options[:wrap_with]
|
||||||
@components << Single.new(name, wrapper)
|
@components << Single.new(name, wrapper, options.except(:wrap_with))
|
||||||
else
|
else
|
||||||
@components << Leaf.new(name)
|
@components << Leaf.new(name, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
module SimpleForm
|
module SimpleForm
|
||||||
module Wrappers
|
module Wrappers
|
||||||
class Leaf
|
class Leaf
|
||||||
attr_reader :namespace
|
attr_reader :namespace, :options
|
||||||
|
|
||||||
def initialize(namespace)
|
def initialize(namespace, options={})
|
||||||
@namespace = namespace
|
@namespace = namespace
|
||||||
|
@options = options
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(input)
|
def render(input)
|
||||||
|
|
|
@ -2,8 +2,8 @@ module SimpleForm
|
||||||
module Wrappers
|
module Wrappers
|
||||||
# `Single` is an optimization for a wrapper that has only one component.
|
# `Single` is an optimization for a wrapper that has only one component.
|
||||||
class Single < Many
|
class Single < Many
|
||||||
def initialize(name, options={})
|
def initialize(name, wrapper_options={}, options={})
|
||||||
super(name, [Leaf.new(name)], options)
|
super(name, [Leaf.new(name, options)], wrapper_options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(input)
|
def render(input)
|
||||||
|
|
Loading…
Reference in New Issue