Class: Adminpanel::AdminpanelFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Adminpanel::AdminpanelFormBuilder
- Defined in:
- app/helpers/adminpanel/adminpanel_form_builder.rb
Instance Method Summary collapse
- #append_field(name, *args) ⇒ Object
- #boolean(name, *args) ⇒ Object
-
#checkbox(checkbox_object, form_object_name, relationship) ⇒ Object
def radio_button_group(name, buttons, options) options.reverse_merge! :label => name options.reverse_merge! :html => {} output = "".
- #datepicker(name, *args) ⇒ Object
- #email_field(name, *args) ⇒ Object
- #email_field_original ⇒ Object
- #file_field(name, *args) ⇒ Object
- #file_field_original ⇒ Object
- #gallery_field(name, *args) ⇒ Object
- #input_layout(name, *args, parent_method) ⇒ Object
- #number_field(name, *args) ⇒ Object
- #number_field_original ⇒ Object
- #password_field(name, *args) ⇒ Object
- #password_field_original ⇒ Object
- #prepend_field(name, *args) ⇒ Object
- #select(name, select_options, *args) ⇒ Object
- #submit(name, *args) ⇒ Object
- #text_area(name, *args) ⇒ Object
- #text_area_original ⇒ Object
- #text_field(name, *args) ⇒ Object
- #text_field_original ⇒ Object
- #wysiwyg_field(name, *args) ⇒ Object
Instance Method Details
#append_field(name, *args) ⇒ Object
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 218 def append_field(name, *args) = args. .reverse_merge! :label => name label = ['label'] .delete('label') .reverse_merge! :symbol => "#" symbol = [:symbol] .delete(:symbol) @template.content_tag :div, :class => "control-group" do @template.content_tag(:label, label, :class => "control-label") + @template.content_tag( :div, @template.content_tag( :div, text_field_original(name, *args << ) + @template.content_tag(:span, symbol, :class => "add-on"), :class => "input-append" ), :class => "controls" ) end end |
#boolean(name, *args) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 97 def boolean(name, *args) = args. @template.content_tag( :div, @template.content_tag( :div, ['label'], :class => 'control-label') + @template.content_tag( :div, @template.content_tag( :label, check_box( name ), :class => 'checkbox' ), :class => 'controls' ), :class => 'control-group' ) end |
#checkbox(checkbox_object, form_object_name, relationship) ⇒ Object
def radio_button_group(name, buttons, options) options.reverse_merge! :label => name options.reverse_merge! :html => {} output = ""
.each do |b|
output += @template.content_tag(:label, (name, b, [:html]) + b.capitalize, :class => "radio")
end
@template.content_tag :div, :class => "control-group" do
@template.content_tag(:label, [:label], :class => "control-label") +
@template.content_tag(:div, output, { :class => "controls"}, false)
end
end
85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 85 def checkbox(checkbox_object, form_object_name, relationship) @template.content_tag( :label, @template.check_box_tag( "#{form_object_name}[#{relationship}][]", checkbox_object.id, self.object.send(relationship).include?(checkbox_object.id) ) + checkbox_object.name, :class => "checkbox" ) end |
#datepicker(name, *args) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 153 def datepicker(name, *args) = args. .reverse_merge! :value => Time.now.strftime("%d-%m-%Y") .reverse_merge! :label => name label = ['label'] .delete('label') @template.content_tag :div, :class => "control-group" do @template.content_tag(:label, label, :class => "control-label") + @template.content_tag( :div, @template.content_tag( :div, text_field_original(name, *args << ) + @template.content_tag( :span, @template.content_tag( :i, nil, :class => "fa fa-th" ), :class => "add-on" ), { :class => "input-append date span5 datepicker datepicker-basic", :data => { :date_format => "dd-mm-yyyy", :date => [:value] } } ), :class => "controls" ) end end |
#email_field(name, *args) ⇒ Object
142 143 144 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 142 def email_field(name, *args) input_layout( name, *args, 'email_field_original' ) end |
#email_field_original ⇒ Object
9 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 9 alias_method :email_field_original, :email_field |
#file_field(name, *args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 16 def file_field(name, *args) image = input_layout(name, *args, 'file_field_original') if object.nil? || object.new_record? image else thumbnail = @template.content_tag :div, :class => 'control-group' do @template.content_tag :div, :class => 'controls' do @template.image_tag object.send("#{name}_url", :thumb) end end "#{thumbnail}#{image}".html_safe end end |
#file_field_original ⇒ Object
10 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 10 alias_method :file_field_original, :file_field |
#gallery_field(name, *args) ⇒ Object
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 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 32 def gallery_field(name, *args) = args. label = ['label'] .delete('label') @template.content_tag :div, :class => "control-group" do label = @template.content_tag(:label, label, :class => "control-label") input = @template.content_tag :div, :class => "controls" do input = file_field_original(name, *args << ) hidden_input = hidden_field(:_destroy) = @template.content_tag(:button, I18n.t("action.delete"), :class => "btn btn-danger remove_fields") if object.nil? || object.new_record? "#{input}#{hidden_input}#{}".html_safe else thumbnail = @template.content_tag :div, :class => 'control-group' do @template.image_tag object.send("#{name}_url", :thumb) end "#{thumbnail}#{input}#{hidden_input}#{}".html_safe end end "#{label}#{input}".html_safe end end |
#input_layout(name, *args, parent_method) ⇒ Object
245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 245 def input_layout(name, *args, parent_method) = args. .reverse_merge! class: 'span7' label = ['label'] .delete('label') @template.content_tag :div, :class => 'control-group' do @template.content_tag(:label, label, :class => 'control-label') + @template.content_tag(:div, :class => 'controls') do self.send(parent_method, name, ) end end end |
#number_field(name, *args) ⇒ Object
134 135 136 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 134 def number_field(name, *args) input_layout( name, *args, 'number_field_original' ) end |
#number_field_original ⇒ Object
8 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 8 alias_method :number_field_original, :number_field |
#password_field(name, *args) ⇒ Object
138 139 140 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 138 def password_field(name, *args) input_layout( name, *args, 'password_field_original' ) end |
#password_field_original ⇒ Object
7 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 7 alias_method :password_field_original, :password_field |
#prepend_field(name, *args) ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 191 def prepend_field(name, *args) = args. .reverse_merge! :label => name label = ['label'] .delete('label') .reverse_merge! :symbol => "#" symbol = [:symbol] .delete(:symbol) @template.content_tag :div, :class => "control-group" do @template.content_tag(:label, label, :class => "control-label") + @template.content_tag( :div, @template.content_tag( :div, @template.content_tag(:span, symbol, :class => "add-on") + text_field_original(name, *args << ), :class => "input-prepend" ), :class => "controls" ) end end |
#select(name, select_options, *args) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 121 def select(name, , *args) = args. label = ['label'] .delete('label') .reverse_merge! :class => 'span7', :include_blank => '(Seleccione por favor)'; @template.content_tag :div, :class => "control-group" do @template.content_tag(:label, label, :class => "control-label") + @template.content_tag(:div, super(name, , ), :class => "controls") end end |
#submit(name, *args) ⇒ Object
146 147 148 149 150 151 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 146 def submit(name, *args) = args. .reverse_merge! :class => "btn btn-primary" super(name, *args << ) end |
#text_area(name, *args) ⇒ Object
66 67 68 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 66 def text_area(name, *args) input_layout( name, *args, 'text_area_original' ) end |
#text_area_original ⇒ Object
6 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 6 alias_method :text_area_original, :text_area |
#text_field(name, *args) ⇒ Object
12 13 14 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 12 def text_field(name, *args) input_layout( name, *args, 'text_field_original' ) end |
#text_field_original ⇒ Object
4 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 4 alias_method :text_field_original, :text_field |
#wysiwyg_field(name, *args) ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/helpers/adminpanel/adminpanel_form_builder.rb', line 58 def wysiwyg_field(name, *args) = args. .reverse_merge! class: 'wysihtml5 span7' input_layout( name, , 'text_area_original' ) end |