From d87b86c7b0f3a73f09a204c13e61a967673a7046 Mon Sep 17 00:00:00 2001 From: Nicholas Zaillian Date: Sun, 17 Mar 2013 15:14:58 -0400 Subject: [PATCH 1/2] update README to upstream (Formtastic) 2.2+ API spec --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 47a5c985..922f56d4 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ made to generate the HTML expected by Bootstrap while still generating the rich <%= f.input :title, :hint => "This is the title!" %> <% end %> <%= f.actions do %> - <%= f.submit %> + <%= f.action :submit %> <% end %> <% end %> From 057f70844addf83709b882290e518ed61be4ee49 Mon Sep 17 00:00:00 2001 From: Nicholas Zaillian Date: Sun, 17 Mar 2013 15:53:58 -0400 Subject: [PATCH 2/2] Adding bootstrap-friendly "semantic_errors" helper (and accompanying passing spec) --- lib/formtastic-bootstrap/form_builder.rb | 1 + .../helpers/errors_helper.rb | 70 +++++++++++ spec/helpers/semantic_errors_helper_spec.rb | 112 ++++++++++++++++++ .../stylesheets/formtastic-bootstrap.css | 4 + 4 files changed, 187 insertions(+) create mode 100644 lib/formtastic-bootstrap/helpers/errors_helper.rb create mode 100644 spec/helpers/semantic_errors_helper_spec.rb diff --git a/lib/formtastic-bootstrap/form_builder.rb b/lib/formtastic-bootstrap/form_builder.rb index 8a524e0e..c3de423a 100644 --- a/lib/formtastic-bootstrap/form_builder.rb +++ b/lib/formtastic-bootstrap/form_builder.rb @@ -31,6 +31,7 @@ def self.default_hint_class=(hint_class) include FormtasticBootstrap::Helpers::InputHelper # Revisit include FormtasticBootstrap::Helpers::InputsHelper + include FormtasticBootstrap::Helpers::ErrorsHelper include FormtasticBootstrap::Helpers::ActionHelper include FormtasticBootstrap::Helpers::ActionsHelper # include Formtastic::Helpers::ErrorsHelper diff --git a/lib/formtastic-bootstrap/helpers/errors_helper.rb b/lib/formtastic-bootstrap/helpers/errors_helper.rb new file mode 100644 index 00000000..4c956f4c --- /dev/null +++ b/lib/formtastic-bootstrap/helpers/errors_helper.rb @@ -0,0 +1,70 @@ +module FormtasticBootstrap + module Helpers + module ErrorsHelper + include Formtastic::Helpers::FileColumnDetection + include Formtastic::Helpers::Reflection + include Formtastic::LocalizedString + + INLINE_ERROR_TYPES = [:sentence, :list, :first] + + # Generates a bootstrap error alert element containing + # an unordered list of error messages on the base object and optionally for a given + # set of named attribute. This is idea for rendering a block of error messages at the top of + # the form for hidden/special/virtual attributes (the Paperclip Rails plugin does this), or + # errors on the base model. + # + # A hash can be used as the last set of arguments to pass HTML attributes to the `