Module: ActiveScaffold::Helpers::FormColumnHelpers
- Included in:
- ViewHelpers
- Defined in:
- lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/form_ui.rb,
lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/country_helpers.rb,
lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb
Overview
Helpers that assist with the rendering of a Form Column
Instance Method Summary collapse
-
#active_scaffold_add_existing_input(options) ⇒ Object
AST Begin.
- #active_scaffold_add_existing_label ⇒ Object
-
#active_scaffold_input_boolean(column, options) ⇒ Object
Column.type-based inputs.
- #active_scaffold_input_checkbox(column, options) ⇒ Object
-
#active_scaffold_input_country(column, options) ⇒ Object
AST active_scaffold_input_country.
- #active_scaffold_input_file_column(column, options) ⇒ Object
-
#active_scaffold_input_for(column, scope = nil, options = {}) ⇒ Object
(also: #form_column)
This method decides which input to use for the given column.
- #active_scaffold_input_hidden(column, options) ⇒ Object
-
#active_scaffold_input_options(column, scope = nil, options = {}) ⇒ Object
the standard active scaffold options used for class, name and scope AST - (cf - verify_request), options param.
- #active_scaffold_input_password(column, options) ⇒ Object
- #active_scaffold_input_percentage(column, options) ⇒ Object
- #active_scaffold_input_phone_number(column, options) ⇒ Object
- #active_scaffold_input_plural_association(column, options) ⇒ Object
- #active_scaffold_input_radio(column, html_options) ⇒ Object
-
#active_scaffold_input_record_select(column, options) ⇒ Object
only works for singular associations requires RecordSelect plugin to be installed and configured.
- #active_scaffold_input_select(column, html_options) ⇒ Object
-
#active_scaffold_input_singular_association(column, html_options) ⇒ Object
Form input methods.
- #active_scaffold_input_ssn(column, options) ⇒ Object (also: #active_scaffold_input_social_security_number)
-
#active_scaffold_input_text_options(options = {}) ⇒ Object
the standard active scaffold options used for textual inputs.
- #active_scaffold_input_textarea(column, options) ⇒ Object
- #active_scaffold_input_timezone(column, options) ⇒ Object
- #active_scaffold_input_true_false_radio(column, options) ⇒ Object
-
#active_scaffold_input_usa_money(column, options) ⇒ Object
:usa_money requires some type casting help like the following in your Model.
-
#active_scaffold_input_usa_state(column, options) ⇒ Object
AST active_scaffold_input_usa_state.
- #active_scaffold_input_usa_zip_code(column, options) ⇒ Object
- #active_scaffold_input_virtual(column, options) ⇒ Object
- #active_scaffold_input_yes_no_radio(column, options) ⇒ Object
- #active_scaffold_observe(column, scope = nil, options = {}) ⇒ Object
-
#column_renders_as(column) ⇒ Object
Macro-level rendering decisions for columns.
- #column_scope(column) ⇒ Object
- #form_partial_for_column(column) ⇒ Object
- #is_subform?(column) ⇒ Boolean
- #is_subsection?(column) ⇒ Boolean
- #javascript_for_update_column(column, scope, options) ⇒ Object
- #onsubmit ⇒ Object
-
#override_form_field(column) ⇒ Object
the naming convention for overriding form fields with helpers.
- #override_form_field?(column) ⇒ Boolean
-
#override_form_field_partial(column) ⇒ Object
the naming convention for overriding form fields with partials.
- #override_form_field_partial?(column) ⇒ Boolean
-
#override_input(form_ui) ⇒ Object
the naming convention for overriding form input types with helpers.
- #override_input?(form_ui) ⇒ Boolean
- #override_subform_partial(column, subform_partial) ⇒ Object
-
#override_subform_partial?(column, subform_partial) ⇒ Boolean
add functionality for overriding subform partials from association class path.
- #remote_image_submit_tag(source, options) ⇒ Object
- #subform_partial_for_column(column) ⇒ Object
Instance Method Details
#active_scaffold_add_existing_input(options) ⇒ Object
AST Begin
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 353 def active_scaffold_add_existing_input() if controller.respond_to?(:record_select_config) remote_controller = active_scaffold_controller_for(record_select_config.model).controller_path = {:controller => remote_controller, :params => {:parent_model => record_select_config.model}} .merge!() record_select_field([:name], @record, ) # record_select_field( # "#{options[:name]}", # active_scaffold_config.model.new, # {:controller => remote_controller, :params => options[:url_options].merge(:parent_model => record_select_config.model)}.merge(active_scaffold_input_text_options)) else # select_options = options_for_select(options_for_association(nested_association)) unless column.through_association? ||= (active_scaffold_config.model.find(:all).collect {|c| [h(c.to_label), c.id]}) unless .empty? select_tag 'associated_id', '<option value="">' + as_(:_select_) + '</option>' + end end end |
#active_scaffold_add_existing_label ⇒ Object
372 373 374 375 376 377 378 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 372 def active_scaffold_add_existing_label if controller.respond_to?(:record_select_config) record_select_config.model.to_s.underscore.humanize else active_scaffold_config.model.to_s.underscore.humanize end end |
#active_scaffold_input_boolean(column, options) ⇒ Object
Column.type-based inputs
245 246 247 248 249 250 251 252 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 245 def active_scaffold_input_boolean(column, ) = [] << [as_(:_select_), nil] if column.column.null << [as_(:true), true] << [as_(:false), false] select_tag([:name], (, @record.send(column.name)), ) end |
#active_scaffold_input_checkbox(column, options) ⇒ Object
205 206 207 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 205 def active_scaffold_input_checkbox(column, ) check_box(:record, column.name, ) end |
#active_scaffold_input_country(column, options) ⇒ Object
AST active_scaffold_input_country
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 210 def active_scaffold_input_country(column, ) # AST Begin #priority = ["United States"] = {:prompt => as_(:_select_)} .merge!() if defined?(localized_country_select) priority = column.[:priority] || [:US] = .merge(column..except(:priority)) localized_country_select(:record, column.name, priority, , ) else priority = column.[:priority] || ["United States"] country_select(:record, column.name, priority, , column.) end # AST End end |
#active_scaffold_input_file_column(column, options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/form_ui.rb', line 5 def active_scaffold_input_file_column(column, ) if @record.send(column.name) # we already have a value? display the form for deletion. content_tag( :div, content_tag( :div, get_column_value(@record, column) + " " + hidden_field(:record, "delete_#{column.name}", :value => "false") + " | " + link_to_function(as_(:remove_file), "$(this).previous().value='true'; p=$(this).up(); p.hide(); p.next().show();"), {} ) + content_tag( :div, file_column_field("record", column.name, ), :style => "display: none" ), {} ) else # no, just display the file_column_field # AST - let's enjoy some of the AS formatting file_column_field("record", column.name, .merge((:class => "#{column.name}-input"))) end end |
#active_scaffold_input_for(column, scope = nil, options = {}) ⇒ Object Also known as: form_column
This method decides which input to use for the given column. It does not do any rendering. It only decides which method is responsible for rendering. AST - (cf - verify_request), options param
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 8 def active_scaffold_input_for(column, scope = nil, = {}) begin # AST - (cf - verify_request), options = (column, scope, ) = javascript_for_update_column(column, scope, ) # first, check if the dev has created an override for this specific field if override_form_field?(column) # AST - I like column and options as params send(override_form_field(column), @record, column, ) # second, check if the dev has specified a valid form_ui for this column elsif column.form_ui and override_input?(column.form_ui) send(override_input(column.form_ui), column, ) # fallback: we get to make the decision else if column.association # if we get here, it's because the column has a form_ui but not one ActiveScaffold knows about. raise "Unknown form_ui `#{column.form_ui}' for column `#{column.name}'" elsif column.virtual? active_scaffold_input_virtual(column, ) else # regular model attribute column # if we (or someone else) have created a custom render option for the column type, use that if override_input?(column.column.type) send(override_input(column.column.type), column, ) # final ultimate fallback: use rails' generic input method else # for textual fields we pass different options text_types = [:text, :string, :integer, :float, :decimal] = () if text_types.include?(column.column.type) if column.column.type == :string && [:maxlength].blank? [:maxlength] = column.column.limit [:size] ||= ActionView::Helpers::InstanceTag::DEFAULT_FIELD_OPTIONS["size"] end .update(:value => format_number_value(@record.send(column.name), column.)) if column.column.number? input(:record, column.name, .merge(column.)) + active_scaffold_observe(column, scope, ) end end end rescue Exception => e logger.error Time.now.to_s + "#{e.inspect} -- on the ActiveScaffold column = :#{column.name} in #{@controller.class}" raise e end end |
#active_scaffold_input_hidden(column, options) ⇒ Object
393 394 395 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 393 def active_scaffold_input_hidden(column, ) input(:record, column.name, .merge(:type => :hidden)) end |
#active_scaffold_input_options(column, scope = nil, options = {}) ⇒ Object
the standard active scaffold options used for class, name and scope AST - (cf - verify_request), options param
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 63 def (column, scope = nil, = {}) # AST Begin - upper_case_form_fields if active_scaffold_config.upper_case_form_fields and column.column and [:text, :string].include?(column.column.type) and column.form_ui.nil? and (!column..has_key?(:upper_case_form_fields) or column.[:upper_case_form_fields] != false) [:onchange] ||= '' .merge!(:onchange => [:onchange] + "ToUpper(this);") end # Allow override of :class [:class] ||= "#{column.name}-input" # AST End name = scope ? "record#{scope}[#{column.name}]" : "record[#{column.name}]" # Fix for keeping unique IDs in subform id_control = "record_#{column.name}_#{[params[:eid], params[:id]].compact.join '_'}" id_control += scope.gsub(/(\[|\])/, '_').gsub('__', '_').gsub(/_$/, '') if scope # AST - cf - verify_request, options { :name => name, :class => "#{column.name}-input", :id => id_control}.merge() end |
#active_scaffold_input_password(column, options) ⇒ Object
217 218 219 220 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 217 def active_scaffold_input_password(column, ) = () password_field :record, column.name, .merge(column.) end |
#active_scaffold_input_percentage(column, options) ⇒ Object
415 416 417 418 419 420 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 415 def active_scaffold_input_percentage(column, ) column.description ||= as_(:percentage_example) [:onblur] ||= "PercentageFormat(this);return true;" = () text_field :record, column.name, .merge(:value => number_to_percentage(@record.send(column.name).to_s, :precision => 1)) end |
#active_scaffold_input_phone_number(column, options) ⇒ Object
439 440 441 442 443 444 445 446 447 448 449 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 439 def active_scaffold_input_phone_number(column, ) column.description ||= as_(:phone_example) [:onblur] ||= "PhoneDashAdd(this);return true;" = () if @record.respond_to?("#{column.name}_for_human") value = @record.send("#{column.name}_for_human") else value = usa_number_to_phone(@record.send(column.name).to_s) end text_field :record, column.name, .merge(:value => value) end |
#active_scaffold_input_plural_association(column, options) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 127 def active_scaffold_input_plural_association(column, ) = @record.send(column.association.name).collect {|r| [r.to_label, r.id]} = | (column.association) return content_tag(:span, as_(:no_options), :id => [:id]) if .empty? html = "<ul class=\"checkbox-list\" id=\"#{[:id]}\">" associated_ids = .collect {|a| a[1]} .each_with_index do |option, i| label, id = option this_name = "#{[:name]}[#{i}][id]" this_id = "#{[:id]}_#{i}_id" html << "<li>" html << check_box_tag(this_name, id, associated_ids.include?(id), :id => this_id) html << "<label for='#{this_id}'>" html << label html << "</label>" html << "</li>" end html << '</ul>' html << javascript_tag("new DraggableLists('#{[:id]}')") if column.[:draggable_lists] html end |
#active_scaffold_input_radio(column, html_options) ⇒ Object
171 172 173 174 175 176 177 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 171 def active_scaffold_input_radio(column, ) .update(column.[:html_options] || {}) column.[:options].inject('') do |html, (text, value)| value ||= text html << content_tag(:label, (:record, column.name, value, .merge(:id => [:id] + '-' + value)) + text) end end |
#active_scaffold_input_record_select(column, options) ⇒ Object
only works for singular associations requires RecordSelect plugin to be installed and configured. … maybe this should be provided in a bridge?
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 182 def active_scaffold_input_record_select(column, ) unless column.association raise ArgumentError, "record_select can only work against associations (and #{column.name} is not). A common mistake is to specify the foreign key field (like :user_id), instead of the association (:user)." end remote_controller = active_scaffold_controller_for(column.association.klass).controller_path # if the opposite association is a :belongs_to (in that case association in this class must be has_one or has_many) # then only show records that have not been associated yet if [:has_one, :has_many].include?(column.association.macro) params.merge!({column.association.primary_key_name => ''}) end = {:controller => remote_controller, :id => [:id]} .merge!() .merge!(column.) if column.singular_association? record_select_field([:name], (@record.send(column.name) || column.association.klass.new), ) elsif column.plural_association? record_multi_select_field([:name], @record.send(column.name), ) end end |
#active_scaffold_input_select(column, html_options) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 152 def active_scaffold_input_select(column, ) if column.singular_association? active_scaffold_input_singular_association(column, ) elsif column.plural_association? active_scaffold_input_plural_association(column, ) else = { :selected => @record.send(column.name) } if column..is_a? Hash = column.[:options] .update(column.[:html_options] || {}) .update(column.) else Rails.logger.warn "ActiveScaffold: Setting the options array directly is deprecated for :select form_ui. Set the options array in a hash under options key, such as config.columns[:column_name].options = {:options => [...], ...}" = column. end select(:record, column.name, , , ) end end |
#active_scaffold_input_singular_association(column, html_options) ⇒ Object
Form input methods
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 103 def active_scaffold_input_singular_association(column, ) associated = @record.send(column.association.name) = (column.association) .unshift([ associated.to_label, associated.id ]) unless associated.nil? or .find {|label, id| id == associated.id} selected = associated.nil? ? nil : associated.id method = column.name [:name] += '[id]' = {:selected => selected, :include_blank => as_(:_select_)} # For backwards compatibility, to add method options is needed to set a html_options hash # in other case all column.options will be added as html options if column.[:html_options] .update(column.[:html_options] || {}) .update(column.) else # AST - This message implies that config.columns[:column_name].options = {:html_options => {...}, ...} is required. Why?" # Rails.logger.warn "ActiveScaffold: Column: (#{column.name}) Setting html options directly in a hash is deprecated for :select form_ui. Set the html options hash under html_options key, such as config.columns[:column_name].options = {:html_options => {...}, ...}" .update(column.) end select(:record, method, .uniq, , ) end |
#active_scaffold_input_ssn(column, options) ⇒ Object Also known as:
397 398 399 400 401 402 403 404 405 406 407 408 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 397 def active_scaffold_input_ssn(column, ) column.description ||= as_(:ssn_example) = () if @record.respond_to?("#{column.name}_for_human") value = @record.send("#{column.name}_for_human") else value = usa_number_to_ssn(@record.send(column.name).to_s) end text_field :record, column.name, .merge( :value => value, :onblur => "SsnDashAdd(this);return true;") end |
#active_scaffold_input_text_options(options = {}) ⇒ Object
the standard active scaffold options used for textual inputs
55 56 57 58 59 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 55 def ( = {}) [:autocomplete] = 'off' [:class] = "#{[:class]} text-input".strip end |
#active_scaffold_input_textarea(column, options) ⇒ Object
222 223 224 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 222 def active_scaffold_input_textarea(column, ) text_area(:record, column.name, .merge(:cols => column.[:cols], :rows => column.[:rows], :size => column.[:size])) end |
#active_scaffold_input_timezone(column, options) ⇒ Object
411 412 413 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 411 def active_scaffold_input_timezone(column, ) time_zone_select(:record, column.name) end |
#active_scaffold_input_true_false_radio(column, options) ⇒ Object
467 468 469 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 467 def active_scaffold_input_true_false_radio(column, ) render :partial => '/true_false_radio', :locals => {:column_name => column.name, :options => , :question_text => column.description, :question_type => :yes_or_no} end |
#active_scaffold_input_usa_money(column, options) ⇒ Object
:usa_money requires some type casting help like the following in your Model
def write_attribute(attr, value)
if column_for_attribute(attr).precision
value = BigDecimal(value.gsub(",", "").gsub("$", "")) if value.is_a?(String)
end
super
end
430 431 432 433 434 435 436 437 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 430 def active_scaffold_input_usa_money(column, ) column.description ||= as_(:usa_money_example) [:onblur] ||= "UsaMoney(this);return true;" value = number_to_currency(@record.send(column.name).to_s) unless [:blank_if_nil] == true value ||= "" = () text_field :record, column.name, .merge(:value => value) end |
#active_scaffold_input_usa_state(column, options) ⇒ Object
AST active_scaffold_input_usa_state
227 228 229 230 231 232 233 234 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 227 def active_scaffold_input_usa_state(column, ) = {:prompt => as_(:_select_)} .merge!() .delete(:size) .delete(:prompt) .delete(:priority) usa_state_select(:record, column.name, column.[:priority], , column..merge()) end |
#active_scaffold_input_usa_zip_code(column, options) ⇒ Object
451 452 453 454 455 456 457 458 459 460 461 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 451 def active_scaffold_input_usa_zip_code(column, ) column.description ||= as_(:usa_zip_example) [:onblur] ||= "UsaZipDashAdd(this);return true;" = () if @record.respond_to?("#{column.name}_for_human") value = @record.send("#{column.name}_for_human") else value = usa_number_to_zip(@record.send(column.name).to_s) end text_field :record, column.name, .merge(:value => value) end |
#active_scaffold_input_virtual(column, options) ⇒ Object
236 237 238 239 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 236 def active_scaffold_input_virtual(column, ) = () text_field :record, column.name, .merge(column.) end |
#active_scaffold_input_yes_no_radio(column, options) ⇒ Object
463 464 465 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 463 def active_scaffold_input_yes_no_radio(column, ) render :partial => '/yes_no_radio', :locals => {:column_name => column.name, :options => } end |
#active_scaffold_observe(column, scope = nil, options = {}) ⇒ Object
380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 380 def active_scaffold_observe(column, scope = nil, = {}) if column.[:observe_method] action = @record.id ? :update : :create = {:action => column.[:observe_method], :id => @record.id, :parent_id => params[:id], :scope => scope} [:controller] = column.[:observe_controller] if column.[:observe_controller] return observe_field((column, scope)[:id], :frequency => 0.2, :url => params_for(), :with => "Form.serialize('#{element_form_id(:action => action)}')+'&='" ) unless !column.[:observe_restrict_actions].nil? and column.[:observe_restrict_actions].include?(action) end '' end |
#column_renders_as(column) ⇒ Object
Macro-level rendering decisions for columns
324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 324 def column_renders_as(column) if column.is_a? ActiveScaffold::DataStructures::ActionColumns return :subsection elsif column.active_record_class.locking_column.to_s == column.name.to_s or column.form_ui == :hidden return :hidden elsif column.association.nil? or column.form_ui or !active_scaffold_config_for(column.association.klass).actions.include?(:subform) return :field else return :subform end end |
#column_scope(column) ⇒ Object
344 345 346 347 348 349 350 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 344 def column_scope(column) if column.plural_association? "[#{column.name}][#{@record.id || generate_temporary_id}]" else "[#{column.name}]" end end |
#form_partial_for_column(column) ⇒ Object
299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 299 def form_partial_for_column(column) if override_form_field_partial?(column) override_form_field_partial(column) elsif column_renders_as(column) == :field or override_form_field?(column) "form_attribute" elsif column_renders_as(column) == :subform "form_association" elsif column_renders_as(column) == :hidden "form_hidden_attribute" end end |
#is_subform?(column) ⇒ Boolean
340 341 342 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 340 def is_subform?(column) column_renders_as(column) == :subform end |
#is_subsection?(column) ⇒ Boolean
336 337 338 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 336 def is_subsection?(column) column_renders_as(column) == :subsection end |
#javascript_for_update_column(column, scope, options) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 82 def javascript_for_update_column(column, scope, ) if column..is_a?(Hash) && column.[:update_column] form_action = :create form_action = :update if params[:action] == 'edit' url_params = {:action => 'render_field', :id => params[:id], :column => column.name, :update_column => column.[:update_column]} url_params[:eid] = params[:eid] if params[:eid] url_params[:controller] = controller.class.active_scaffold_controller_for(@record.class).controller_path if scope url_params[:scope] = params[:scope] if scope = {:method => :get, :url => url_for(url_params), :with => "'value=' + this.value", :after => "$('#{loading_indicator_id(:action => :render_field, :id => params[:id])}').style.visibility = 'visible'; Form.disable('#{element_form_id(:action => form_action)}');", :complete => "$('#{loading_indicator_id(:action => :render_field, :id => params[:id])}').style.visibility = 'hidden'; Form.enable('#{element_form_id(:action => form_action)}');"} [:onchange] = "#{remote_function()};#{[:onchange]}" end end |
#onsubmit ⇒ Object
254 255 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 254 def onsubmit end |
#override_form_field(column) ⇒ Object
the naming convention for overriding form fields with helpers
286 287 288 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 286 def override_form_field(column) "#{column.name}_form_column" end |
#override_form_field?(column) ⇒ Boolean
281 282 283 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 281 def override_form_field?(column) respond_to?(override_form_field(column)) end |
#override_form_field_partial(column) ⇒ Object
the naming convention for overriding form fields with partials
277 278 279 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 277 def override_form_field_partial(column) "#{column.name}_form_column" end |
#override_form_field_partial?(column) ⇒ Boolean
271 272 273 274 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 271 def override_form_field_partial?(column) path, partial_name = partial_pieces(override_form_field_partial(column)) template_exists?(File.join(path, "_#{partial_name}"), true) end |
#override_input(form_ui) ⇒ Object
the naming convention for overriding form input types with helpers
295 296 297 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 295 def override_input(form_ui) "active_scaffold_input_#{form_ui}" end |
#override_input?(form_ui) ⇒ Boolean
290 291 292 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 290 def override_input?(form_ui) respond_to?(override_input(form_ui)) end |
#override_subform_partial(column, subform_partial) ⇒ Object
267 268 269 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 267 def override_subform_partial(column, subform_partial) File.join(active_scaffold_controller_for(column.association.klass).controller_path, subform_partial) if column_renders_as(column) == :subform end |
#override_subform_partial?(column, subform_partial) ⇒ Boolean
add functionality for overriding subform partials from association class path
262 263 264 265 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 262 def override_subform_partial?(column, subform_partial) path, partial_name = partial_pieces(override_subform_partial(column, subform_partial)) template_exists?(File.join(path, "_#{partial_name}")) end |
#remote_image_submit_tag(source, options) ⇒ Object
471 472 473 474 475 476 477 478 479 480 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 471 def remote_image_submit_tag(source, ) [:with] ||= 'Form.serialize(this.form)' [:html] ||= {} [:html][:type] = 'image' [:html][:onclick] = "#{remote_function()}; return false;" [:html][:src] = image_path(source) tag("input", [:html], false) end |
#subform_partial_for_column(column) ⇒ Object
311 312 313 314 315 316 317 318 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb', line 311 def subform_partial_for_column(column) subform_partial = "#{active_scaffold_config_for(column.association.klass).subform.layout}_subform" if override_subform_partial?(column, subform_partial) override_subform_partial(column, subform_partial) else subform_partial end end |