From 998c4569c598d3b64cee3d9579681e319df263e8 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Garcia Ballester Date: Sun, 1 Jul 2012 19:16:05 +0200 Subject: [PATCH] Update README to latest formtastic API --- README.rdoc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/README.rdoc b/README.rdoc index ead58e5..cf80396 100644 --- a/README.rdoc +++ b/README.rdoc @@ -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