Class: Arbre::Rails::Forms::FormForProxy

Inherits:
FormBuilderProxy show all
Defined in:
lib/arbre/rails/forms.rb

Instance Attribute Summary

Attributes inherited from FormBuilderProxy

#form_builder

Instance Method Summary collapse

Methods inherited from FormBuilderProxy

#label, #respond_to_missing?, #select

Methods inherited from Component

#initialize, #tag_name

Constructor Details

This class inherits a constructor from Arbre::Component

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Arbre::Rails::Forms::FormBuilderProxy

Instance Method Details

#build(resource, form_options = {}, &block) ⇒ Object


46
47
48
49
50
51
52
53
# File 'lib/arbre/rails/forms.rb', line 46

def build(resource, form_options = {}, &block)
  form_string = helpers.form_for(resource, form_options) do |f|
    @form_builder = f
  end

  @opening_tag, @closing_tag = split_string_on(form_string, "</form>")
  super(&block)
end

#closing_tagObject


69
70
71
# File 'lib/arbre/rails/forms.rb', line 69

def closing_tag
  @closing_tag || ""
end

#fields_for(*args, &block) ⇒ Object


55
56
57
# File 'lib/arbre/rails/forms.rb', line 55

def fields_for(*args, &block)
  insert_tag FieldsForProxy, form_builder, *args, &block
end

#opening_tagObject


65
66
67
# File 'lib/arbre/rails/forms.rb', line 65

def opening_tag
  @opening_tag || ""
end

#split_string_on(string, match) ⇒ Object


59
60
61
62
63
# File 'lib/arbre/rails/forms.rb', line 59

def split_string_on(string, match)
  return "" unless string && match
  part_1 = string.split(Regexp.new("#{match}\\z")).first
  [part_1, match]
end