lib/active_scaffold/helpers/form_column_helpers.rb
# 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.
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.
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 .
def active_scaffold_file_with_content(column, content, options, remove_file_prefix, controls_class)
        required = options.delete(:required)
        case ActiveScaffold.js_framework
        when :jquery
          js_remove_file_code = "jQuery(this).prev().val('true'); jQuery(this).parent().hide().next().show()#{".find('input').attr('required', 'required')" if required}; return false;"
          js_dont_remove_file_code = "jQuery(this).parents('div.#{controls_class}').find('input.remove_file').val('false'); return false;"
        when :prototype
          js_remove_file_code = "$(this).previous().value='true'; $(this).up().hide().next().show()#{".down().writeAttribute('required', 'required')" if required}; return false;"
          js_dont_remove_file_code = "jQuery(this).parents('div.#{controls_class}').find('input.remove_file').val('false'); return false;"
        end
        object_name, method = options[:name].split(/\[(#{column.name})\]/)
        method.sub!(/#{column.name}/, "#{remove_file_prefix}\\0")
        fields = block_given? ? yield : ''
        link_key = options[:multiple] ? :remove_files : :remove_file
        input = file_field(:record, column.name, options.merge(:onchange => js_dont_remove_file_code))
        content_tag(:div, class: controls_class) do
          content_tag(:div) do
            safe_join [content, ' | ', fields,
                       hidden_field(object_name, method, :value => 'false', class: 'remove_file'),
                       content_tag(:a, as_(link_key), :href => '#', :onclick => js_remove_file_code)]
          end << content_tag(:div, input, :style => 'display: none')
        end
      end
def active_scaffold_file_with_content ( column , content , options , remove_file_prefix , controls_class ) required = options . delete ( :required ) case ActiveScaffold . js_framework when :jquery js_remove_file_code = "jQuery(this).prev().val('true'); jQuery(this).parent().hide().next().show()#{".find('input').attr('required', 'required')" if required}; return false;" js_dont_remove_file_code = "jQuery(this).parents('div.#{controls_class}').find('input.remove_file').val('false'); return false;" when :prototype js_remove_file_code = "$(this).previous().value='true'; $(this).up().hide().next().show()#{".down().writeAttribute('required', 'required')" if required}; return false;" js_dont_remove_file_code = "jQuery(this).parents('div.#{controls_class}').find('input.remove_file').val('false'); return false;" end object_name , method = options [ :name ] . split ( / \[ ( #{ column . name } ) \] / ) method . sub! ( / #{ column . name } / , "#{remove_file_prefix}\\0" ) fields = block_given? ? yield : '' link_key = options [ :multiple ] ? :remove_files : :remove_file input = file_field ( :record , column . name , options . merge ( :onchange => js_dont_remove_file_code ) ) content_tag ( :div , class : controls_class ) do content_tag ( :div ) do safe_join [ content , ' | ' , fields , hidden_field ( object_name , method , :value => 'false' , class : 'remove_file' ) , content_tag ( :a , as_ ( link_key ) , :href => '#' , :onclick => js_remove_file_code ) ] end << content_tag ( :div , input , :style => 'display: none' ) end end
This method decides which input to use for the given column.
This method decides which input to use for the given column .
column
<not_specific>
content
<not_specific>
options
<not_specific>
remove_file_prefix
<not_specific>
controls_class
<not_specific>