lib/pakyow/presenter/presenters/form.rb in pakyow-presenter-1.0.0.rc3 vs lib/pakyow/presenter/presenters/form.rb in pakyow-presenter-1.0.0.rc4
- old
+ new
@@ -84,11 +84,11 @@
end
# Populates a select field with options.
#
def options_for(field, options = nil)
- unless field_presenter = find(field) || find(Support.inflector.singularize(field)) || find(Support.inflector.pluralize(field))
+ unless field_presenter = find(Support.inflector.singularize(field)) || find(Support.inflector.pluralize(field))
raise ArgumentError.new("could not find field named `#{field}'")
end
unless options_for_allowed?(field_presenter)
raise ArgumentError.new("expected `#{field}' to be a select field, checkbox, radio button, or binding")
@@ -209,11 +209,12 @@
end
end
def use_binding_nodes
view.object.set_label(:bound, true)
- view.object.children.each_significant_node(:binding, descend: true) do |object|
+
+ view.object.each_significant_node(:binding, descend: true) do |object|
if Pakyow::Presenter::Views::Form::FIELD_TAGS.include?(object.tagname)
object.set_label(:bound, true)
end
end
end
@@ -335,12 +336,12 @@
end
values = Array.ensure(values).compact
if values.any?
- field_view = Pakyow::Presenter::Views::Form.from_object(field_presenter.view.object)
- field_template = field_view.dup
+ field_view = field_presenter.view
+ field_template = field_view.soft_copy
insertable_field = field_view
current_field = field_view
values.each do |value|
current_field.attributes[:value] = option_value(value, field_presenter.view).to_s
@@ -348,23 +349,23 @@
unless current_field.equal?(field_view)
insertable_field.after(current_field)
insertable_field = current_field
end
- current_field = field_template.dup
+ current_field = field_template.soft_copy
end
else
field_presenter.remove
end
end
def create_options(original_values, field_presenter)
values = Array.ensure(original_values).compact
if values.any?
- field_view = Pakyow::Presenter::Views::Form.from_object(field_presenter.view.object)
- template = field_view.dup
+ field_view = field_presenter.view
+ template = field_view.soft_copy
insertable = field_view
current = field_view
values.each do |value|
if treat_as_nested?(current, value)
@@ -430,10 +431,10 @@
insertable.after(current)
insertable = current
end
current.object.set_label(:bound, true)
- current = template.dup
+ current = template.soft_copy
end
else
field_presenter.remove
end
end