Sha256: 7eb82cbcba6574d00e5e6d1ce11bfc86afbba0bd891f7c5a964cd09c4c296641

Contents?: true

Size: 821 Bytes

Versions: 3

Compression:

Stored size: 821 Bytes

Contents

#
# Code snippet to create a formtastic input
# You can use this code in your custom formbuilder
#
# Usage: form.input :name, :as => :person_name
#

module Formtastic
  module PersonName
    def person_name_input(method, options)
      html_options         = options.delete(:input_html) || {}
      html_options         = default_string_options(method, :person_name).merge(html_options)
      html_options[:class] = [html_options[:class], "person-name"].compact.join(" ")

      part_fields          = PersonName::NameSplitter::NAME_PARTS.collect do |field_part|
        self.hidden_field("#{method}_#{field_part}")
      end.join.html_safe

      self.label(method, options_for_label(options)) <<
          content_tag(:p, self.text_field(method, html_options) << part_fields, :class => "field-group")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
person-name-0.2.13 extras/formtastic_input.rb
person-name-0.2.12 extras/formtastic_input.rb
person-name-0.2.11 extras/formtastic_input.rb