Commit cd305024f6aab45ea47efa5dfa6e13a150493524

Authored by Dan Croak
1 parent d89eda92

updated semi formal with working belongs_to field

Showing 1 changed file with 6 additions and 2 deletions   Show diff stats
vendor/plugins/semi_formal/lib/semi_formal.rb
@@ -42,6 +42,11 @@ class SemiFormal < ActionView::Helpers::FormBuilder @@ -42,6 +42,11 @@ class SemiFormal < ActionView::Helpers::FormBuilder
42 "<div>" 42 "<div>"
43 end 43 end
44 44
  45 + # form.belongs_to :user
  46 + #
  47 + # returns a drop-down with value of User#id, text of User#to_s
  48 + # includes blank
  49 + #
45 def belongs_to(field, *args) 50 def belongs_to(field, *args)
46 options = args.extract_options! 51 options = args.extract_options!
47 52
@@ -53,7 +58,7 @@ class SemiFormal &lt; ActionView::Helpers::FormBuilder @@ -53,7 +58,7 @@ class SemiFormal &lt; ActionView::Helpers::FormBuilder
53 58
54 "<div class=\"belongs_to\">" + 59 "<div class=\"belongs_to\">" +
55 label(field, options[:label] || {}) + 60 label(field, options[:label] || {}) +
56 - select(field, collection, options[:select] || {}) 61 + select(field, collection, options[:select] || {}) +
57 "<div>" 62 "<div>"
58 end 63 end
59 64
@@ -62,7 +67,6 @@ class SemiFormal &lt; ActionView::Helpers::FormBuilder @@ -62,7 +67,6 @@ class SemiFormal &lt; ActionView::Helpers::FormBuilder
62 # html_options[:multiple] ||= true 67 # html_options[:multiple] ||= true
63 # html_options[:size] ||= 5 68 # html_options[:size] ||= 5
64 # end 69 # end
65 -  
66 end 70 end
67 71
68 ActionView::Base.default_form_builder = SemiFormal 72 ActionView::Base.default_form_builder = SemiFormal