neorails-form_fu 0.3 → 0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -74,7 +74,10 @@ Usage
74
74
  <%= f.error_messages %>
75
75
 
76
76
  --------
77
-
77
+
78
+ Access the originals form_for helpers (prepend _input to names)
79
+ <%= f.text_field_input :name %>
80
+ outputs only a text_field input tag
78
81
 
79
82
  Try my other plugins
80
83
  ======
data/form_fu.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'form_fu'
3
- s.version = '0.3'
3
+ s.version = '0.4'
4
4
  s.date = '2008-07-06'
5
5
 
6
6
  s.summary = "Build Nice DRY Rails Forms"
@@ -3,15 +3,17 @@ module FormFu
3
3
  # A form builder that produces tableless, lined-up forms.
4
4
  class FormBuilder < ActionView::Helpers::FormBuilder
5
5
  # automatically wrap all the standard formbuilder helpers
6
- (field_helpers - %w(label hidden_field radio_button check_box text_area apply_form_for_options!)).each do |selector|
6
+ (field_helpers - %w(label hidden_field text_area select apply_form_for_options!)).each do |selector|
7
7
  src = <<-END_SRC
8
+ alias :#{selector}_input :#{selector}
8
9
  def #{selector}(field, options = {}, &block)
9
10
  format_with_label(field, options.merge(:field_type => "#{selector}"), super(field, purge_custom_tags(options)), &block)
10
11
  end
11
12
  END_SRC
12
13
  class_eval src, __FILE__, __LINE__
13
14
  end
14
-
15
+
16
+ alias :text_area_input :text_area
15
17
  def text_area(field, options = {}, &block)
16
18
  format_with_label(field, options.merge(:field_type => "text_area", :preserve => true), super(field, purge_custom_tags(options)), &block)
17
19
  end
@@ -36,7 +38,7 @@ module FormFu
36
38
  # build radio choices html
37
39
  choices_html = ""
38
40
  choices.each do |key, value|
39
- radio_html = radio_button(field, value)+key
41
+ radio_html = radio_button_input(field, value)+key
40
42
 
41
43
  # wrap radio html in a label (for easier selection)
42
44
  choices_html << @template.content_tag(:label, radio_html, :class => "radio-option")
@@ -47,6 +49,7 @@ module FormFu
47
49
  end
48
50
 
49
51
  # wrap the select helper
52
+ alias :select_input :select
50
53
  def select(field, choices, options={}, &block)
51
54
  html_options = options.delete(:html) || {}
52
55
  format_with_label(field, options.merge(:field_type => "select"), super(field, choices, options, html_options), &block)
@@ -83,8 +86,14 @@ module FormFu
83
86
  tag_output = @template.preserve(tag_output)
84
87
  end
85
88
 
89
+ # find label name
90
+ label_name = options[:label] || field.to_s.humanize
91
+ options[:separator] ||= default_separator
92
+ label_name = "#{label_name}#{options.delete(:separator)}"
93
+
94
+ # build output html
86
95
  output_html = @template.field_tag(options[:field], [
87
- @template.label(@object_name, field, options[:label], :separator => options[:separator] || default_separator),
96
+ @template.label(@object_name, field, label_name),
88
97
  tag_output,
89
98
  @template.validation_tag(@object, field),
90
99
  block_given? ? @template.capture(&block) : nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neorails-form_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.3"
4
+ version: "0.4"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Crocker