Module: Erubis::Helpers::RailsFormHelper

### Home Classes Methods

### In Files

- lib/erubis/helpers/rails_form_helper.rb

### Methods

- #_pp_check_box_checked?
- #_pp_error_tags
- #_pp_radio_button_checked?
- #_pp_remove_error_div
- #_pp_select
- #_pp_select_options
- #pp_check_box
- #pp_collection_select
- #pp_country_select
- #pp_error_on
- #pp_file_field
- #pp_form_tag
- #pp_hidden_field
- #pp_image_submit_tag
- #pp_password_field
- #pp_radio_button
- #pp_render_partial
- #pp_select
- #pp_submit_tag
- #pp_tag_helper
- #pp_template_filename
- #pp_text_area
- #pp_text_field
- #pp_time_zone_select

### Class/Module Index

Quicksearch

- Erubis
- Erubis::ArrayBufferEnhancer
- Erubis::ArrayBufferEruby
- Erubis::ArrayEnhancer
- Erubis::ArrayEruby
- Erubis::Basic
- Erubis::Basic::Converter
- Erubis::Basic::Engine
- Erubis::BiPatternEnhancer
- Erubis::BiPatternEruby
- Erubis::CGenerator
- Erubis::CommandOptionError
- Erubis::Context
- Erubis::Converter
- Erubis::CppGenerator
- Erubis::DeleteIndentEnhancer
- Erubis::DeleteIndentEruby
- Erubis::Ec
- Erubis::Ecpp
- Erubis::Ejava
- Erubis::Ejavascript
- Erubis::Ejs
- Erubis::Engine
- Erubis::Eperl
- Erubis::Ephp
- Erubis::ErboutEnhancer
- Erubis::ErboutEruby
- Erubis::ErubisError
- Erubis::Eruby
- Erubis::EscapeEnhancer
- Erubis::EscapedEc
- Erubis::EscapedEcpp
- Erubis::EscapedEjava
- Erubis::EscapedEjavascript
- Erubis::EscapedEjs
- Erubis::EscapedEperl
- Erubis::EscapedEphp
- Erubis::EscapedEruby
- Erubis::EscapedEscheme
- Erubis::Escheme
- Erubis::Evaluator
- Erubis::FastEruby
- Erubis::Generator
- Erubis::HeaderFooterEnhancer
- Erubis::HeaderFooterEruby
- Erubis::Helpers
- Erubis::Helpers::RailsFormHelper
- Erubis::Helpers::RailsHelper
- Erubis::Helpers::RailsHelper::TemplateConverter
- Erubis::InterpolationEnhancer
- Erubis::InterpolationEruby
- Erubis::JavaGenerator
- Erubis::JavascriptGenerator
- Erubis::Main
- Erubis::NoCodeEnhancer
- Erubis::NoCodeEruby
- Erubis::NoTextEnhancer
- Erubis::NoTextEruby
- Erubis::NotSupportedError
- Erubis::OptimizedEruby
- Erubis::OptimizedGenerator
- Erubis::OptimizedXmlEruby
- Erubis::PI
- Erubis::PI::Converter
- Erubis::PI::Ec
- Erubis::PI::Ecpp
- Erubis::PI::Ejava
- Erubis::PI::Ejavascript
- Erubis::PI::Engine
- Erubis::PI::Eperl
- Erubis::PI::Ephp
- Erubis::PI::Eruby
- Erubis::PI::Escheme
- Erubis::PI::TinyEruby
- Erubis::PercentLineEnhancer
- Erubis::PercentLineEruby
- Erubis::PerlGenerator
- Erubis::PhpGenerator
- Erubis::PrefixedLineEnhancer
- Erubis::PrefixedLineEruby
- Erubis::PreprocessingEruby
- Erubis::PreprocessingHelper
- Erubis::PrintEnabledEnhancer
- Erubis::PrintEnabledEruby
- Erubis::PrintOutEnhancer
- Erubis::PrintOutEruby
- Erubis::PrintOutSimplifiedEruby
- Erubis::RubyEvaluator
- Erubis::RubyGenerator
- Erubis::SchemeGenerator
- Erubis::SimplifiedEruby
- Erubis::SimplifyEnhancer
- Erubis::StdoutEnhancer
- Erubis::StdoutEruby
- Erubis::StdoutSimplifiedEruby
- Erubis::StringBufferEnhancer
- Erubis::StringBufferEruby
- Erubis::StringIOEruby
- Erubis::TinyEruby
- Erubis::XmlEruby
- Erubis::XmlHelper
- ActionView
- ActionView::TemplateHandlers
- ActionView::TemplateHandlers::ErubisHandler
- ERB
- Kernel

No matching classes.

# Erubis::Helpers::RailsFormHelper

### Public Instance Methods

_pp_check_box_checked?(value, checked_value) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 106
    def _pp_check_box_checked?(value, checked_value)
      return ActionView::Helpers::InstanceTag::check_box_checked?(value, checked_value)
    end

_pp_error_tags(value) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 46
    def _pp_error_tags(value)
      return value ? ['<div class="fieldWithErrors">', '</div>'] : ['', '']
    end

_pp_radio_button_checked?(value, tag_value) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 117
    def _pp_radio_button_checked?(value, tag_value)
      return ActionView::Helpers::InstanceTag::radio_button_checked?(value, tag_value)
    end

_pp_remove_error_div(s) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 50
    def _pp_remove_error_div(s)
      s.sub!(/\A<div class="fieldWithErrors">(.*)<\/div>\z/, '\1')
      return s
    end

_pp_select(object, method, collection, priority_collection, options={}, html_options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 121
    def _pp_select(object, method, collection, priority_collection, options={}, html_options={})
      return pp_error_on(object, method) do
        s = ""
        ## start tag
        s << "<select id=\"#{object}_#{method}\" name=\"#{object}[#{method}]\""
        for key, val in html_options:
            s << " #{key}=\"#{val}\""
        end
        s << ">\n"
        ## selected table
        key = options.key?(:value) ? :value : (options.key?('value') ? 'value' : nil)
        if    key.nil?                ;  selected = "@#{object}.#{method}"
        elsif (val=options[key]).nil? ;  selected = nil
        elsif val =~ /\A<%=(.*)%>\z/  ;  selected = $1
        else                          ;  selected = val.inspect
        end
        s << "<% _table = {#{selected}=>' selected=\"selected\"'} %>\n" if selected
        ## <option> tags
        if options[:include_blank] || options['include_blank']
          s << "<option value=\"\"></option>\n"
        end
        unless priority_collection.blank?
          _pp_select_options(s, priority_collection, selected, 'delete')
          s << "<option value=\"\">-------------</option>\n"
        end
        _pp_select_options(s, collection, selected, '[]')
        ## end tag
        s << "</select>"
        s
      end
    end

_pp_select_options(s, collection, selected, operator) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 153
    def _pp_select_options(s, collection, selected, operator)
      for item in collection
        value, text = item.is_a?(Array) ? item : [item, item]
        if !selected
          t = ''
        elsif operator == 'delete'
          t = "<%= _table.delete(#{value.inspect}) %>"
        else
          t = "<%= _table[#{value.inspect}] %>"
        end
        s << "<option value=\"#{h value}\"#{t}>#{h text}</option>\n"
      end
    end

pp_check_box(object_name, method, options={}, checked_value="1", unchecked_value="0") click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 99
    def pp_check_box(object_name, method, options={}, checked_value="1", unchecked_value="0")
      s = check_box(object_name, method, options, checked_value, unchecked_value)
      s.sub!(/\schecked=\"checked\"/, '')
      s.sub!(/type="checkbox"/, "\\&<%= _pp_check_box_checked?(@#{object_name}.#{method}, #{checked_value.inspect}) ? ' checked=\"checked\"' : '' %>")
      return pp_error_on(object_name, method) { _pp_remove_error_div(s) }
    end

pp_collection_select(object, method, collection, value_method, text_method, options={}, html_options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 171
    def pp_collection_select(object, method, collection, value_method, text_method, options={}, html_options={})
      collection2 = collection.collect { |e|
        [e.__send__(value_method), e.__send__(text_method)]
      }
      return _pp_select(object, method, collection2, nil, options, html_options)
    end

pp_country_select(object, method, priority_countries=nil, options={}, html_options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 178
    def pp_country_select(object, method, priority_countries=nil, options={}, html_options={})
      collection = ActionView::Helpers::FormOptionsHelper::COUNTRIES
      return _pp_select(object, method, collection, priority_countries, options, html_options)
    end

pp_error_on(object_name, method) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 37
    def pp_error_on(object_name, method)
      s = ''
      s << "<% _stag, _etag = _pp_error_tags(@#{object_name}.errors.on('#{method}')) %>"
      s << "<%= _stag %>"
      s << yield(object_name, method)
      s << "<%= _etag %>"
      return s
    end

pp_file_field(object_name, method, options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 91
    def pp_file_field(object_name, method, options={})
      return pp_tag_helper(:file_field, object_name, method, options)
    end

pp_form_tag(url_for_options={}, options={}, *parameters_for_url, &block) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 69
    def pp_form_tag(url_for_options={}, options={}, *parameters_for_url, &block)
      return form_tag(url_for_options, options, *parameters_for_url, &block)
    end

pp_hidden_field(object_name, method, options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 87
    def pp_hidden_field(object_name, method, options={})
      return pp_tag_helper(:hidden_field, object_name, method, options)
    end

pp_image_submit_tag(source, options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 193
    def pp_image_submit_tag(source, options={})
      return image_submit_tag(source, options)
    end

pp_password_field(object_name, method, options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 83
    def pp_password_field(object_name, method, options={})
      return pp_tag_helper(:password_field, object_name, method, options)
    end

pp_radio_button(object_name, method, tag_value, options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 110
    def pp_radio_button(object_name, method, tag_value, options={})
      s = radio_button(object_name, method, tag_value, options)
      s.sub!(/\schecked=\"checked\"/, '')
      s.sub!(/type="radio"/, "\\&<%= _pp_radio_button_checked?(@#{object_name}.#{method}, #{tag_value.inspect}) ? ' checked=\"checked\"' : '' %>")
      return pp_error_on(object_name, method) { _pp_remove_error_div(s) }
    end

pp_render_partial(basename) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 30
    def pp_render_partial(basename)
      basename = "_#{basename}" unless basename[0] == __
      filename = pp_template_filename(basename)
      preprocessor = _create_preprocessor(File.read(filename))
      return preprocessor.evaluate(_preprocessing_context_object())
    end

pp_select(object, method, collection, options={}, html_options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 167
    def pp_select(object, method, collection, options={}, html_options={})
      return _pp_select(object, method, collection, nil, options, html_options)
    end

pp_submit_tag(value="Save changes", options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 189
    def pp_submit_tag(value="Save changes", options={})
      return submit_tag(value, options)
    end

pp_tag_helper(helper, object_name, method, options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 55
    def pp_tag_helper(helper, object_name, method, options={})
      if object_name.is_a?(ActionView::Helpers::FormHelper)
        object_name = object_name.object_name
      end
      unless options.key?(:value) || options.key?('value')
        options['value'] = _?("h @#{object_name}.#{method}")
      end
      #$stderr.puts "*** debug: pp_tag_helper(): options=#{options.inspect}"
      return pp_error_on(object_name, method) {
        s = __send__(helper, object_name, method, options)
        _pp_remove_error_div(s)
      }
    end

pp_template_filename(basename) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 19
    def pp_template_filename(basename)
      return "#{RAILS_ROOT}/app/views/#{controller.controller_name}/#{basename}.rhtml"
    end

pp_text_area(object_name, method, options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 95
    def pp_text_area(object_name, method, options={})
      return pp_tag_helper(:text_area, object_name, method, options)
    end

pp_text_field(object_name, method, options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 79
    def pp_text_field(object_name, method, options={})
      return pp_tag_helper(:text_field, object_name, method, options)
    end

pp_time_zone_select(object, method, priority_zones=nil, options={}, html_options={}) click to toggle source

    # File lib/erubis/helpers/rails_form_helper.rb, line 183
    def pp_time_zone_select(object, method, priority_zones=nil, options={}, html_options={})
      model = options[:model] || options['model'] || TimeZone
      collection = model.all.collect { |e| [e.name, e.to_s] }
      return _pp_select(object, method, collection, priority_zones, options, html_options)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.