Permalink
Browse files

Merge pull request #86 from mjbellantoni/bootstrap3_and_rails4

Add support for Bootstrap 3
  • Loading branch information...
2 parents 95fed68 + d185a2d commit 6758345cae893286f1edf230a295bc1994192c16 @mjbellantoni committed Nov 25, 2013
View
@@ -1,97 +1,81 @@
PATH
remote: .
specs:
- formtastic-bootstrap (2.1.3)
- formtastic (~> 2.2)
+ formtastic-bootstrap (3.0.0.rc.1)
+ formtastic (>= 2.2)
GEM
remote: https://rubygems.org/
specs:
- actionpack (3.2.13)
- activemodel (= 3.2.13)
- activesupport (= 3.2.13)
- builder (~> 3.0.0)
+ actionpack (4.0.1)
+ activesupport (= 4.0.1)
+ builder (~> 3.1.0)
erubis (~> 2.7.0)
- journey (~> 1.0.4)
- rack (~> 1.4.5)
- rack-cache (~> 1.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.2.1)
- activemodel (3.2.13)
- activesupport (= 3.2.13)
- builder (~> 3.0.0)
- activesupport (3.2.13)
- i18n (= 0.6.1)
- multi_json (~> 1.0)
+ rack (~> 1.5.2)
+ rack-test (~> 0.6.2)
+ activesupport (4.0.1)
+ i18n (~> 0.6, >= 0.6.4)
+ minitest (~> 4.2)
+ multi_json (~> 1.3)
+ thread_safe (~> 0.1)
+ tzinfo (~> 0.3.37)
ammeter (0.2.9)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (>= 2.2)
rspec-rails (>= 2.2)
- builder (3.0.4)
- diff-lcs (1.1.3)
+ atomic (1.1.14)
+ builder (3.1.4)
+ diff-lcs (1.2.5)
erubis (2.7.0)
formtastic (2.2.1)
actionpack (>= 3.0)
- hike (1.2.3)
- i18n (0.6.1)
- journey (1.0.4)
- json (1.8.0)
- multi_json (1.7.7)
+ i18n (0.6.5)
+ minitest (4.7.5)
+ multi_json (1.8.2)
nokogiri (1.5.10)
- rack (1.4.5)
- rack-cache (1.2)
- rack (>= 0.4)
- rack-ssl (1.3.3)
- rack
+ rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
- railties (3.2.13)
- actionpack (= 3.2.13)
- activesupport (= 3.2.13)
- rack-ssl (~> 1.3.2)
+ railties (4.0.1)
+ actionpack (= 4.0.1)
+ activesupport (= 4.0.1)
rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (>= 0.14.6, < 2.0)
+ thor (>= 0.18.1, < 2.0)
rake (10.1.0)
- rdoc (3.12.2)
- json (~> 1.4)
- rspec (2.8.0)
- rspec-core (~> 2.8.0)
- rspec-expectations (~> 2.8.0)
- rspec-mocks (~> 2.8.0)
- rspec-core (2.8.0)
- rspec-expectations (2.8.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.8.0)
- rspec-rails (2.8.1)
+ rspec (2.14.1)
+ rspec-core (~> 2.14.0)
+ rspec-expectations (~> 2.14.0)
+ rspec-mocks (~> 2.14.0)
+ rspec-core (2.14.7)
+ rspec-expectations (2.14.4)
+ diff-lcs (>= 1.1.3, < 2.0)
+ rspec-mocks (2.14.4)
+ rspec-rails (2.14.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
- rspec (~> 2.8.0)
+ rspec-core (~> 2.14.0)
+ rspec-expectations (~> 2.14.0)
+ rspec-mocks (~> 2.14.0)
rspec_tag_matchers (1.0.0)
nokogiri (>= 1.4.0)
rspec-rails (>= 1.2.6)
- sprockets (2.2.2)
- hike (~> 1.2)
- multi_json (~> 1.0)
- rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
thor (0.18.1)
- tilt (1.4.1)
- tzinfo (1.0.1)
+ thread_safe (0.1.3)
+ atomic
+ tzinfo (0.3.38)
PLATFORMS
ruby
DEPENDENCIES
- actionpack (~> 3.0)
+ actionpack
ammeter (~> 0.2.5)
- bundler (~> 1.2)
+ bundler
formtastic-bootstrap!
nokogiri (< 1.6.0)
rake
- rspec (~> 2.8.0)
- rspec-rails (~> 2.8.0)
+ rspec-rails
rspec_tag_matchers (>= 1.0.0)
tzinfo
View
@@ -8,7 +8,27 @@ You can follow [FormBoot on twitter](http://twitter.com/FormBoot) for update ann
### Dependencies
-Formtastic Bootstrap has only been tested with Ruby 1.9.2, Rails 3.2.x, Formtastic 2.2.x and Twitter Bootstrap 2.x.
+This version of Formtastic Bootstrap should support the following:
+
+*Bootstrap*
+
+* Bootstrap 3.x
+
+*Rails*
+
+* Rails 3.2.x
+* Rails 4.0.x
+
+*Formtastic*
+
+* Formtastic 2.2.x
+* Formtastic 2.3.x
+
+*Ruby*
+
+* 1.9.2
+* 1.9.3
+* 2.0.x
#### Installation
@@ -43,58 +63,12 @@ THIS SECTION IS OUT OF DATE.
### Overview
-In general, Formtastic creates very verbose HTML whereas Bootstrap expects simpler HTML. Every attempt has been
-made to generate the HTML expected by Bootstrap while still generating the rich HTML provided by Formtastic. Here's a pretty typical (simplified) example of what Formtastic generates and what Formtastic Bootstrap generates.
-
-#### ERB
-
- <%= semantic_form_for @post do |f| %>
- <%= f.semantic_errors %>
- <%= f.inputs do %>
- <%= f.input :title, :hint => "This is the title!" %>
- <% end %>
- <%= f.actions do %>
- <%= f.action :submit %>
- <% end %>
- <% end %>
+In general, Formtastic creates very verbose HTML whereas
+Bootstrap expects (ever) simpler HTML. Every attempt has been
+made to generate the HTML expected by Bootstrap while still
+generating the rich HTML provided by Formtastic. When there
+is a conflict, Bootstrap wins.
-#### Formtastic
-
- <form accept-charset="UTF-8" action="/posts" class="formtastic post" id="new_post" method="post">
- <fieldset class="inputs">
- <ol>
- <li class="string input optional stringish" id="post_title_input">
- <label class=" label" for="post_title">Title</label>
- <input id="post_title" maxlength="255" name="post[title]" type="text" value="" />
- <p class="inline-hints">This is the title!</p>
- </li>
- </ol>
- </fieldset>
- <fieldset class="buttons">
- <ol>
- <li class="commit button">
- <input class="create" name="commit" type="submit" value="Create Post" />
- </li>
- </ol>
- </fieldset>
- </form>
-
-#### Formtastic Bootstrap
-
- <form accept-charset="UTF-8" action="/posts" class="formtastic post" id="new_post" method="post">
- <fieldset class="inputs">
- <div class="string clearfix optional stringish" id="post_title_input">
- <label class="" for="post_title">Title</label>
- <div class="input">
- <input id="post_title" maxlength="255" name="post[title]" type="text" value="" />
- <span class="help-inline">This is the title!</span>
- </div>
- </div>
- </fieldset>
- <div class="actions">
- <input class="btn create commit" name="commit" type="submit" value="Create Post" />
- </div>
- </form>
### Major Difference in Behavior
@@ -114,7 +88,10 @@ The gem also provides some "shim" CSS where Bootstrap is missing styles provided
### Other
-A lot of the code (especially the test suite) was copied over from Formtastic and then beaten into submission. I'm sure you'll find some ugliness in there. In general, I mimicked the Formtastic code structure as much as possible.
+A lot of the code (especially the test suite) was copied
+over from Formtastic and then beaten into submission. I'm
+sure you'll find some ugliness in there. In general, I
+mimicked the Formtastic code structure as much as possible.
In particular:
@@ -130,7 +107,7 @@ In particular:
Contributions are welcome!
* Formtastic's <tt>:country</tt> has not yet been implemented.
-* Twitter Bootstrap's Date Range, Prepend Checkbox and Appended Checkbox controls have not yet been implemented.
+* I'm sure there's lots ...
## Usage
@@ -208,16 +185,16 @@ Source contributions are very welcome! Most of the recent work on this package
* As rich functionally as their Rails counterparts.
* Extract into a standalone gem.
* Tests
+ * Get them passing!
* Refactor
* More -- See if I'm making sure the Bootstrap classes are present.
* Documentation
* Refactor :boolean to use common "choices" code (if possible.) (Not sure it is.)
* Boostrap
- * Ask why they use 'inline-inputs' class instead of a fieldset tag.
* Why 'help-inline' and 'help-block' when they could have done p.help and span.help?
## Copyright
-Copyright (c) 2011 Matthew Bellantoni. See LICENSE.txt for further details.
+Copyright (c) 2013 Matthew Bellantoni. See LICENSE.txt for further details.
View
@@ -1 +1 @@
-2.1.3
+3.0.0.rc.1
@@ -24,15 +24,14 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.rubygems_version = "1.8.10"
- s.add_dependency('formtastic', ["~> 2.2"])
+ s.add_dependency('formtastic', [">= 2.2"])
s.add_development_dependency('rake')
s.add_development_dependency('tzinfo')
- s.add_development_dependency('bundler', ["~> 1.2"])
+ s.add_development_dependency('bundler')
s.add_development_dependency('nokogiri', ["< 1.6.0"])
- s.add_development_dependency('rspec', ["~> 2.8.0"])
- s.add_development_dependency('rspec-rails', ["~> 2.8.0"])
+ s.add_development_dependency('rspec-rails')
s.add_development_dependency('rspec_tag_matchers', [">= 1.0.0"])
s.add_development_dependency('ammeter', ["~> 0.2.5"])
- s.add_development_dependency('actionpack', ["~> 3.0"])
+ s.add_development_dependency('actionpack')
end
@@ -5,6 +5,12 @@ module Html
include Formtastic::Inputs::Base::Html
+ def form_control_input_html_options
+ orig_class = input_html_options[:class]
+ new_class = [orig_class, "form-control"].compact.join(" ")
+ input_html_options.merge(:class => new_class)
+ end
+
def input_html_options
if errors?
{
@@ -7,20 +7,15 @@ module Labelling
def label_html_options
super.tap do |options|
- # Bootstrap defines class 'label'
+ # Bootstrap defines class 'label' too, so remove the
+ # one that gets created by Formtastic.
options[:class] = options[:class].reject { |c| c == 'label' }
- # options[:class] << "control-label"
end
end
- def control_label_html_options
- label_html_options.tap do |options|
- options[:class] << "control-label"
- end
- end
-
- def control_label_html
- render_label? ? builder.label(input_name, label_text, control_label_html_options) : "".html_safe
+ # def control_label_html
+ def label_html
+ render_label? ? builder.label(input_name, label_text, label_html_options) : "".html_safe
end
end
@@ -7,7 +7,7 @@ module Stringish
def to_html
bootstrap_wrapping do
- builder.text_field(method, input_html_options)
+ builder.text_field(method, form_control_input_html_options)
end
end
Oops, something went wrong.

0 comments on commit 6758345

Please sign in to comment.