Module: Padrino::Helpers::FormBuilder::DeprecatedBuilderMethods

### Home Classes Methods

### In Files

- lib/padrino-helpers/form_builder/deprecated_builder_methods.rb

### Methods

- #field_error
- #field_result
- #merge_default_options!
- #nested_form?
- #object_class
- #object_model_name
- #result_options
- #root_form?
- #values_matches_field?

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Padrino
- Padrino::Helpers
- Padrino::Helpers::AssetTagHelpers
- Padrino::Helpers::FormBuilder
- Padrino::Helpers::FormBuilder::AbstractFormBuilder
- Padrino::Helpers::FormBuilder::DeprecatedBuilderMethods
- Padrino::Helpers::FormBuilder::StandardFormBuilder
- Padrino::Helpers::FormHelpers
- Padrino::Helpers::FormHelpers::Errors
- Padrino::Helpers::FormHelpers::Options
- Padrino::Helpers::FormHelpers::Security
- Padrino::Helpers::NumberHelpers
- Padrino::Helpers::OutputHelpers
- Padrino::Helpers::OutputHelpers::AbstractHandler
- Padrino::Helpers::OutputHelpers::ErbHandler
- Padrino::Helpers::OutputHelpers::HamlHandler
- Padrino::Helpers::OutputHelpers::SinatraCurrentEngine
- Padrino::Helpers::OutputHelpers::SlimHandler
- Padrino::Helpers::RenderHelpers
- Padrino::Helpers::TagHelpers
- Padrino::Helpers::TranslationHelpers
- Padrino::Rendering
- Padrino::Rendering::ClassMethods
- Padrino::Rendering::ErubisTemplate
- Padrino::Rendering::HamlTemplate
- Padrino::Rendering::InstanceMethods
- Padrino::Rendering::SafeBufferEnhancer
- Padrino::Rendering::SafeEruby
- Padrino::Rendering::SafeTemplate
- Padrino::Rendering::SlimTemplate
- Padrino::Rendering::TemplateNotFound
- Haml
- Haml::Helpers
- Haml::Util

No matching classes.

# Padrino::Helpers::FormBuilder::DeprecatedBuilderMethods

### Public Instance Methods

field_error(field, options) click to toggle source

Add a :invalid css class to the field if it contain an error.

    # File lib/padrino-helpers/form_builder/deprecated_builder_methods.rb, line 16
    def field_error(field, options)
      logger.warn "##{__method__} is deprecated"
      error = @object.errors[field] rescue nil
      error.blank? ? options[:class] : [options[:class], :invalid].flatten.compact.join(" ")
    end

field_result() click to toggle source

    # File lib/padrino-helpers/form_builder/deprecated_builder_methods.rb, line 55
    def field_result
      logger.warn "##{__method__} is deprecated"
      result = []
      result << object_model_name if root_form?
      result
    end

merge_default_options!(field, options) click to toggle source

    # File lib/padrino-helpers/form_builder/deprecated_builder_methods.rb, line 62
    def merge_default_options!(field, options)
      logger.warn "##{__method__} is deprecated"
      options.reverse_merge!(:value => field_value(field), :id => field_id(field))
      options.merge!(:class => field_error(field, options))
    end

nested_form?() click to toggle source

    # File lib/padrino-helpers/form_builder/deprecated_builder_methods.rb, line 22
    def nested_form?
      logger.warn "##{__method__} is deprecated"
      @options[:nested] && @options[:nested][:parent] && @options[:nested][:parent].respond_to?(:object)
      is_nested && object.respond_to?(:new_record?) && !object.new_record? && object.id
    end

object_class(explicit_object) click to toggle source

Returns the class type for the given object.

    # File lib/padrino-helpers/form_builder/deprecated_builder_methods.rb, line 40
    def object_class(explicit_object)
      logger.warn "##{__method__} is deprecated"
      explicit_object.is_a?(Symbol) ? explicit_object.to_s.camelize.constantize : explicit_object.class
      @object.respond_to?(field) ? @object.send(field) : ''
    end

object_model_name(explicit_object=object) click to toggle source

Returns the object's models name.

    # File lib/padrino-helpers/form_builder/deprecated_builder_methods.rb, line 31
    def object_model_name(explicit_object=object)
      logger.warn "##{__method__} is deprecated"
      return @options[:as] if root_form? && @options[:as].is_a?(Symbol)
      explicit_object.is_a?(Symbol) ? explicit_object : explicit_object.class.to_s.underscore.gsub(/\//, '_')
    end

result_options() click to toggle source

    # File lib/padrino-helpers/form_builder/deprecated_builder_methods.rb, line 68
    def result_options
      logger.warn "##{__method__} is deprecated"
      {
        :parent_form  => @options[:nested][:parent],
        :nested_index => @options[:nested][:index],
        :attributes_name => "#{@options[:nested][:association]}_attributes"
      }
    end

root_form?() click to toggle source

Returns true if this form is the top-level (not nested). Returns a record from template instance or create a record of specified class.

    # File lib/padrino-helpers/form_builder/deprecated_builder_methods.rb, line 50
    def root_form?
      logger.warn "##{__method__} is deprecated"
      !nested_form?
    end

values_matches_field?(field, value) click to toggle source

Returns true if the value matches the value in the field. field_has_value?(:gender, 'male')

    # File lib/padrino-helpers/form_builder/deprecated_builder_methods.rb, line 8
    def values_matches_field?(field, value)
      logger.warn "##{__method__} is deprecated"
      value.present? && (field_value(field).to_s == value.to_s || field_value(field).to_s == 'true')
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.