We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Fork of shift/accessible_form_builder
Description: Major refactoring, blueprint support, bare_ accessors to original methods.
Homepage: http://voidcontext.lighthouseapp.com/projects/9016-grid_forms/
Clone URL: git://github.com/jlindley/accessible_form_builder.git
Fixed inconsistant spacing.
jlindley (author)
Tue Mar 11 12:42:06 -0700 2008
commit  3619f504083a4d8f3355e80f5e92d1480ff104e8
tree    614b12d4f3851122c4d4ec4ffe05747b7919e87a
parent  1709ae5a56f4371943c36f4b4b2ec56f35f6c842
...
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
 
 
 
 
 
 
 
 
 
 
 
 
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
 
 
 
 
 
 
 
 
 
 
 
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
126
...
28
29
30
 
 
 
 
 
 
 
 
 
 
 
 
 
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
 
 
 
 
 
 
 
 
 
 
 
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
0
@@ -28,99 +28,99 @@ module AccessibleForm
0
        class_eval src, __FILE__, __LINE__
0
      end
0
 
0
- def submit(text, options = {})
0
- generic_field(nil, @template.submit_tag(text, options), nil, options)
0
- end
0
-
0
- def file_column_field(field, options = {})
0
- field = field.to_s
0
- label_text, required, note = extract_paf_options(field, options)
0
- generic_field(field, @template.file_column_field(@object_name, field, options), label_text, {:required => required, :note => note})
0
- end
0
-
0
- def separator(new_section_name, options = {})
0
- return options[:html] unless options[:html].blank?
0
- <<-HTML
0
+ def submit(text, options = {})
0
+ generic_field(nil, @template.submit_tag(text, options), nil, options)
0
+ end
0
+
0
+ def file_column_field(field, options = {})
0
+ field = field.to_s
0
+ label_text, required, note = extract_paf_options(field, options)
0
+ generic_field(field, @template.file_column_field(@object_name, field, options), label_text, {:required => required, :note => note})
0
+ end
0
+
0
+ def separator(new_section_name, options = {})
0
+ return options[:html] unless options[:html].blank?
0
+ <<-HTML
0
     </ol>
0
   </fieldset>
0
   <fieldset><legend>#{new_section_name}</legend>
0
     <ol>
0
- HTML
0
- end
0
-
0
- protected
0
- def generic_field(fieldname, field, label_text = nil, options = {})
0
- required = options[:required] ? @template.content_tag('span', '*', :class => 'requiredField') : ''
0
- note = options[:note] ? @template.content_tag('em', " #{options[:note]}") : ''
0
- unless label_text.blank?
0
- if options[:label] == :after
0
- li(field + label(label_text, "#{@object_name}_#{fieldname}", true) + required + note)
0
- else
0
- li(
0
+ HTML
0
+ end
0
+
0
+ protected
0
+ def generic_field(fieldname, field, label_text = nil, options = {})
0
+ required = options[:required] ? @template.content_tag('span', '*', :class => 'requiredField') : ''
0
+ note = options[:note] ? @template.content_tag('em', " #{options[:note]}") : ''
0
+ unless label_text.blank?
0
+ if options[:label] == :after
0
+ li(field + label(label_text, "#{@object_name}_#{fieldname}", true) + required + note)
0
+ else
0
+ li(
0
               label(label_text, "#{@object_name}_#{fieldname}") +
0
               field + required + note
0
- )
0
- end
0
- else # No label
0
- li(field + required + note)
0
- end
0
- end
0
-
0
- def li content, options = {}
0
- @template.content_tag 'li', content, options
0
- end
0
-
0
- def label text, for_field, after = false
0
- @template.content_tag 'label', "#{text}#{after ? '' : ':'}", :for => for_field
0
- end
0
-
0
- def extract_paf_options field, options
0
- label_text = options.delete(:label) || field.to_s.humanize
0
- required = options.delete(:required) || false
0
- note = options.delete(:note) || false
0
- [label_text, required, note]
0
- end
0
- end
0
-
0
- def a_form_for(object_name, *args, &proc)
0
- options = args.last.is_a?(Hash) ? args.last : {}
0
- if options[:html].nil? then
0
- options[:html] = { :class => "aFrm" }
0
- else
0
- options[:html][:class] = (options[:html][:class].nil?) ? "aFrm" : "#{options[:html][:class]} aFrm"
0
- end
0
- legend = options.delete :legend
0
- if legend.blank?
0
- prefix = options[:prefix].blank? ? "<fieldset><ol>" : options[:prefix]
0
- postfix = options[:postfix].blank? ? "</fieldset></ol>" : options[:postfix]
0
- else
0
- prefix = options[:prefix].blank? ? "<fieldset><legend>#{legend}</legend><ol>" : options[:prefix]
0
- postfix = options[:postfix].blank? ? '</ol></fieldset>' : options[:postfix]
0
- end
0
-
0
- custom_form_for(
0
- PAFormBuilder, prefix, postfix,
0
- form_tag(options.delete(:url) || {}, options.delete(:html) || {}),
0
- object_name, *args, &proc)
0
- end
0
-
0
- def a_remote_form_for(object_name, *args, &proc)
0
- options = args.last.is_a?(Hash) ? args.last : {}
0
- if options[:html].nil? then
0
- options[:html] = { :class => "aFrm" }
0
- else
0
- options[:html][:class] = (options[:html][:class].nil?) ? "aFrm" : "#{options[:html][:class]} aFrm"
0
- end
0
- legend = options.delete :legend
0
- if legend.blank?
0
- prefix = options[:prefix].blank? ? "<fieldset><ol>" : options[:prefix]
0
- postfix = options[:postfix].blank? ? "</ol></fieldset>" : options[:postfix]
0
- else
0
- prefix = options[:prefix].blank? ? "<fieldset><legend>#{legend}</legend><ol>" : options[:prefix]
0
- postfix = options[:postfix].blank? ? '</ol></fieldset>' : options[:postfix]
0
- end
0
- custom_form_for(PAFormBuilder, prefix, postfix, form_remote_tag(options), object_name, *args, &proc)
0
- end
0
- end
0
+ )
0
+ end
0
+ else # No label
0
+ li(field + required + note)
0
+ end
0
+ end
0
+
0
+ def li content, options = {}
0
+ @template.content_tag 'li', content, options
0
+ end
0
+
0
+ def label text, for_field, after = false
0
+ @template.content_tag 'label', "#{text}#{after ? '' : ':'}", :for => for_field
0
+ end
0
+
0
+ def extract_paf_options field, options
0
+ label_text = options.delete(:label) || field.to_s.humanize
0
+ required = options.delete(:required) || false
0
+ note = options.delete(:note) || false
0
+ [label_text, required, note]
0
+ end
0
+ end
0
+
0
+ def a_form_for(object_name, *args, &proc)
0
+ options = args.last.is_a?(Hash) ? args.last : {}
0
+ if options[:html].nil? then
0
+ options[:html] = { :class => "aFrm" }
0
+ else
0
+ options[:html][:class] = (options[:html][:class].nil?) ? "aFrm" : "#{options[:html][:class]} aFrm"
0
+ end
0
+ legend = options.delete :legend
0
+ if legend.blank?
0
+ prefix = options[:prefix].blank? ? "<fieldset><ol>" : options[:prefix]
0
+ postfix = options[:postfix].blank? ? "</fieldset></ol>" : options[:postfix]
0
+ else
0
+ prefix = options[:prefix].blank? ? "<fieldset><legend>#{legend}</legend><ol>" : options[:prefix]
0
+ postfix = options[:postfix].blank? ? '</ol></fieldset>' : options[:postfix]
0
+ end
0
+
0
+ custom_form_for(
0
+ PAFormBuilder, prefix, postfix,
0
+ form_tag(options.delete(:url) || {}, options.delete(:html) || {}),
0
+ object_name, *args, &proc)
0
+ end
0
+
0
+ def a_remote_form_for(object_name, *args, &proc)
0
+ options = args.last.is_a?(Hash) ? args.last : {}
0
+ if options[:html].nil? then
0
+ options[:html] = { :class => "aFrm" }
0
+ else
0
+ options[:html][:class] = (options[:html][:class].nil?) ? "aFrm" : "#{options[:html][:class]} aFrm"
0
+ end
0
+ legend = options.delete :legend
0
+ if legend.blank?
0
+ prefix = options[:prefix].blank? ? "<fieldset><ol>" : options[:prefix]
0
+ postfix = options[:postfix].blank? ? "</ol></fieldset>" : options[:postfix]
0
+ else
0
+ prefix = options[:prefix].blank? ? "<fieldset><legend>#{legend}</legend><ol>" : options[:prefix]
0
+ postfix = options[:postfix].blank? ? '</ol></fieldset>' : options[:postfix]
0
+ end
0
+ custom_form_for(PAFormBuilder, prefix, postfix, form_remote_tag(options), object_name, *args, &proc)
0
+ end
0
+end
0
 
0
 

Comments

    No one has commented yet.