3 # Abstraction to make views a little cleaner
4 def form_input(helper_method, prompt, field_name=nil, options = {}, form_name = nil)
5 form_name = "user" if form_name.nil?
6 case helper_method.to_s
8 self.hidden_field(form_name, field_name, options)
10 #prompt = l(:"#{@controller.controller_name}_#{field_name}_button")
12 <tr><td class="button" colspan="2">
13 #{self.send(helper_method, form_name, prompt, options)}
20 self.send(helper_method, form_name, field_name, options.delete('values'), options)
23 self.send(helper_method, form_name, field_name, options)
25 self.send(helper_method, form_name, field_name, options)
27 # lname = "#{form_name}_#{field_name}_form"
28 # prompt = l(:"#{lname}")
29 if LoginEngine.config(:two_column_input)
31 <tr class="two_columns">
32 <td class="prompt"><label>#{prompt}:</label></td>
33 <td class="value">#{field}</td>
38 <tr><td class="prompt"><label>#{prompt}:</label></td></tr>
39 <tr><td class="value">#{field}</td></tr>
45 # def button_helper(name, options = {})
46 # label = l(:"#{@controller.controller_name}_#{name}_button")
47 # "#{self.send(:submit_tag, label, options)}"
50 # def link_helper(name, options = {})
51 # raise ArgumentError if name.nil?
52 # label = l(:"#{@controller.controller_name}_#{name}_link")
53 # "#{self.send(:link_to, label, options)}"
57 "#{@controller.controller_class_name} #{@controller.action_name}"
60 # def message_helper(name)
61 # l(:"#{@controller.controller_name}_#{name}_message")
64 def start_form_tag_helper(options = {})
65 url = url_for(:action => "#{@controller.action_name}")
66 "#{self.send(:start_form_tag, url, options)}"
70 hash.keys.inject("") { |attrs, key| attrs + %{#{key}="#{h(hash[key])}" } }
73 def read_only_field(form_name, field_name, html_options)
74 "<span #{attributes(html_options)}>#{instance_variable_get('@' + form_name)[field_name]}</span>"
77 def submit_button(form_name, prompt, html_options)
78 %{<input name="submit" type="submit" value="#{prompt}" />}
81 def changeable(user, field)
82 if user.new_record? or LoginEngine.config(:changeable_fields).include?(field)