mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Store the component on the instance
We already own the component so we don't need to ask for it again
This commit is contained in:
parent
724dff54d5
commit
3d53595112
1 changed files with 4 additions and 6 deletions
|
@ -3,23 +3,21 @@ module SimpleForm
|
|||
# `Single` is an optimization for a wrapper that has only one component.
|
||||
class Single < Many
|
||||
def initialize(name, wrapper_options = {}, options = {})
|
||||
super(name, [Leaf.new(name, options)], wrapper_options)
|
||||
@component = Leaf.new(name, options)
|
||||
|
||||
super(name, [@component], wrapper_options)
|
||||
end
|
||||
|
||||
def render(input)
|
||||
options = input.options
|
||||
if options[namespace] != false
|
||||
content = component.render(input)
|
||||
content = @component.render(input)
|
||||
wrap(input, options, content) if content
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def component
|
||||
components.first
|
||||
end
|
||||
|
||||
def html_options(options)
|
||||
[:label, :input].include?(namespace) ? {} : super
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue