Class: Adminpanel::CustomFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Adminpanel::CustomFormBuilder
- Defined in:
- app/helpers/adminpanel/custom_form_builder.rb
Instance Method Summary collapse
- #append_field(name, *args) ⇒ Object
- #checkbox(checkbox_object, form_object_name, relationship) ⇒ Object
- #datepicker(name, *args) ⇒ Object
- #file_field(name, *args) ⇒ Object
- #gallery_field(name, *args) ⇒ Object
- #number_field(name, *args) ⇒ Object
- #parent_file_field ⇒ Object
- #password_field(name, *args) ⇒ Object
- #prepend_field(name, *args) ⇒ Object
- #radio_button_group(name, buttons, options) ⇒ Object
- #select(name, select_options, *args) ⇒ Object
- #submit(name, *args) ⇒ Object
- #text_area(name, *args) ⇒ Object
- #text_field(name, *args) ⇒ Object
- #text_field_original ⇒ Object
- #wysiwyg_field(name, *args) ⇒ Object
Instance Method Details
#append_field(name, *args) ⇒ Object
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 256 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 |
#checkbox(checkbox_object, form_object_name, relationship) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 114 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
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 217 218 219 220 221 222 223 224 225 226 227 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 191 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 => "icon-th" ), :class => "add-on" ), { :class => "input-append date span5 datepicker datepicker-basic", :data => { :date_format => "dd-mm-yyyy", :date => [:value] } } ), :class => "controls" ) end end |
#file_field(name, *args) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 21 def file_field(name, *args) = args. label = ['label'] .delete('label') image = @template.content_tag :div, :class => "control-group" do @template.content_tag(:label, label, :class => "control-label") + @template.content_tag(:div, super(name, *args << ), :class => "controls") end 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 |
#gallery_field(name, *args) ⇒ Object
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 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 45 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 = parent_file_field(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 |
#number_field(name, *args) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 141 def number_field(name, *args) = args. .reverse_merge! :class => "span5" .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, super(name, *args << ), :class => "controls") end end |
#parent_file_field ⇒ Object
6 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 6 alias_method :parent_file_field, :file_field |
#password_field(name, *args) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 155 def password_field(name, *args) = args. .reverse_merge! :class => "span7" # options.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, super(name, *args << ), :class => "controls") end end |
#prepend_field(name, *args) ⇒ Object
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 229 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 |
#radio_button_group(name, buttons, options) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 98 def (name, , ) .reverse_merge! :label => name .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 |
#select(name, select_options, *args) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 126 def select(name, , *args) = args. .reverse_merge! :class => "span7" .reverse_merge! :include_blank => "(Seleccione por favor)"; label = [:label] .delete(:label) @template.content_tag :div, :class => "control-group" do @template.content_tag(:label, label, :class => "control-label") + @template.content_tag(:div, super(name, , *args << ), :class => "controls") end end |
#submit(name, *args) ⇒ Object
184 185 186 187 188 189 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 184 def submit(name, *args) = args. .reverse_merge! :class => "btn btn-primary" super(name, *args << ) end |
#text_area(name, *args) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 169 def text_area(name, *args) = args. .reverse_merge! :class => "span7" .reverse_merge! :rows => "10" .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, super(name, *args << ), :class => "controls") end end |
#text_field(name, *args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 8 def text_field(name, *args) = 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, super(name, *args << ), :class => "controls") end end |
#text_field_original ⇒ Object
4 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 4 alias_method :text_field_original, :text_field |
#wysiwyg_field(name, *args) ⇒ Object
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 |
# File 'app/helpers/adminpanel/custom_form_builder.rb', line 71 def wysiwyg_field(name, *args) = args. 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 if self.object.send(name).nil? @template.content_tag( :div, self.object.send(name), :id => name, "data-placeholder" => I18n.t("Write description here") ) else @template.content_tag( :div, self.object.send(name).html_safe, :id => name, "data-placeholder" => I18n.t("Write description here") ) end end end end |