Skip to content

Commit

Permalink
Merge pull request jeffp#51 from giga/master
Browse files Browse the repository at this point in the history
Update README to latest Formtastic API
  • Loading branch information
turadg committed Jul 2, 2012
2 parents 56c3506 + 998c456 commit 84221b8
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -507,19 +507,21 @@ You can display the select input in a Formtastic form with a little monkey patch
require 'formtastic'

module Formtastic #:nodoc:
class SemanticFormBuilder #:nodoc:
def enum_input(method, options)
unless options[:collection]
enum = @object.enums(method.to_sym)
choices = enum ? enum.select_options : []
options[:collection] = choices
module Inputs #:nodoc:
class EnumInput < SelectInput #:nodoc:
def to_html
unless options[:collection]
enum = @object.enums(method.to_sym)
choices = enum ? enum.select_options : []
options[:collection] = choices
end
if (value = @object.__send__(method.to_sym))
options[:selected] ||= value.to_s
else
options[:include_blank] ||= true
end
super
end
if (value = @object.__send__(method.to_sym))
options[:selected] ||= value.to_s
else
options[:include_blank] ||= true
end
select_input(method, options)
end
end
end
Expand Down

0 comments on commit 84221b8

Please sign in to comment.