formtastic 1.0.0.beta2 → 1.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -77,20 +77,33 @@ h2. Documentation
77
77
  RDoc documentation _should_ be automatically generated after each commit and made available on the "rdoc.info website":http://rdoc.info/projects/justinfrench/formtastic.
78
78
 
79
79
 
80
- h2. Installation
80
+ h2. A Note About Rails 3 Support
81
81
 
82
- The gem is hosted on gemcutter, so *if you haven't already*, add it as a gem source:
82
+ Formtastic 1.0 will only support the latest stable Rails 2.x. We're maintaining a rails3 branch which aims to provide both Rails 2.x and 3.x support, which is targeted for the 1.1 release soon after 1.0, around the same time Rails 3.0 ships.
83
+
84
+ If you have a Rails 3 project and would like to use Formtastic's rails3 branch, bundler provides you with the ability to do this easily. Just add Formtastic as a git dependency in your Gemfile with the :branch option:
83
85
 
84
86
  <pre>
85
- sudo gem sources -a http://gemcutter.org/
87
+ gem 'formtastic', :git => "http://github.com/justinfrench/formtastic.git", :branch => "rails3"
86
88
  </pre>
87
89
 
88
- Then install the Formtastic gem:
90
+ Please be aware that Rails 3 is still under heavy development (even in the later betas), as is Formtastic, so our rails3 branch is very much "on the edge", just like Rails. if you find issues, compatibility issues with Rails 2 or 3, please report an issue on Github.
91
+
92
+
93
+ h2. Installation under Rails 2.x
94
+
95
+ Install the Formtastic gem:
89
96
 
90
97
  <pre>
91
98
  sudo gem install formtastic
92
99
  </pre>
93
100
 
101
+ Or try the 1.0.0.beta2:
102
+
103
+ <pre>
104
+ sudo gem install formtastic --pre
105
+ </pre>
106
+
94
107
  And add it to your environment.rb configuration as a gem dependency:
95
108
 
96
109
  <pre>
@@ -113,6 +126,7 @@ A proof-of-concept stylesheet is provided which you can include in your layout.
113
126
  </head>
114
127
  </pre>
115
128
 
129
+
116
130
  h2. Usage
117
131
 
118
132
  Forms are really boring to code... you want to get onto the good stuff as fast as possible.
@@ -524,9 +538,11 @@ By default formtastic escapes html entities in both labels and hints unless a st
524
538
  Formtastic::SemanticFormBuilder.escape_html_entities_in_hints_and_labels = false
525
539
 
526
540
 
527
- h2. Status
541
+ h2. Focus
528
542
 
529
- Formtastic has been in active development for about a year. We've just recently jumped to an 0.9 version number, signaling that we consider this a 1.0 release candidate, and that the API won't change significantly for the 1.x series.
543
+ Formtastic is close to shipping a 1.0 release candidate after more than a year of active development. 1.0 will be compatible with Rails 2, and this is our top priority right now. We've also been working hard on a Rails 2 *and* 3 compatible version in the rails3 branch, targeting a 1.1 release shortly after Rails 3.0 ships.
544
+
545
+ There's heaps more we want to do, but we have to do this first.
530
546
 
531
547
 
532
548
  h2. Dependencies
@@ -540,18 +556,14 @@ There are none, but...
540
556
 
541
557
  h2. Compatibility
542
558
 
543
- I'm only testing Formtastic with the latest Rails 2.4.x stable release, and it should be fine under Rails 2.3.x as well (including nested forms). Patches are welcome to allow backwards compatibility, but I don't have the energy!
544
-
545
- h2. Got TextMate?
546
-
547
- Well...there's a TextMate-bundle in town, dedicated to make usage of Formtastic in the "TextMate":http://macromates.com/ editor even more of a breeze:
548
-
549
- "Formtastic.tmbundle":http://github.com/grimen/formtastic_tmbundle
550
-
559
+ * We're only testing Formtastic with the latest Rails 2.x stable release. Patches are welcome to allow backwards compatibility with older versions of Rails, of course.
560
+ * Development of a Rails 2 *and* 3 compatible version of Formtastic is underway in the rails3 branch, targeting a Formtastic 1.1 release shortly after Rails 3.0 ships.
561
+ * Formtastic, much like Rails 2, is very ActiveRecord-centric. Many people are using Formtastic (especially the rails3 branch) successfully with other ActiveModel-like ORMs and classes (DataMapper, MongoMapper, Mongoid, Authlogic, Devise...) but we're not guaranteeing anything at this stage. Patches are welcome, but it's not our core focus right now. Shipping a solid 1.0 and Rails 3 compatible 1.1 is.
562
+
551
563
 
552
564
  h2. How to contribute
553
565
 
554
- *Before you send a pull request*, please ensure that you provide appropriate spec/test coverage and ensure the documentation is up-to-date. Bonus points if you perform your changes in a clean topic branch rather than master.
566
+ Please ensure that you provide appropriate spec/test coverage and ensure the documentation is up-to-date. Bonus points if you perform your changes in a clean topic branch rather than master, and if you create an issue on GH for us to discuss your changes. Pull requests tend to get lost.
555
567
 
556
568
  Please also keep your commits *atomic* so that they are more likely to apply cleanly. That means that each commit should contain the smallest possible logical change. Don't commit two features at once, don't update the gemspec at the same time you add a feature, don't fix a whole bunch of whitespace in a file at the same time you change a few lines, etc, etc.
557
569
 
@@ -560,7 +572,7 @@ For significant changes, you may wish to discuss your idea on the Formtastic Goo
560
572
 
561
573
  h2. Maintainers & Contributors
562
574
 
563
- Formtastic is maintained by "Justin French":http://justinfrench.com, "José Valim":http://github.com/josevalim and "Jonas Grimfelt":http://github.com/grimen, but it wouldn't be as awesome as it is today without help from over 40 contributors.
575
+ Formtastic is maintained by "Justin French":http://github.com/justinfrench, "Morton Jonuschat":http://github.com/yabawock and "Gabriel Sobrinho":http://github.com/sobrinho. "Denis Major":http://github.com/denismajor1 is doing some amazing documentation work in the wiki, and we very much appreciate the past efforts of "José Valim":http://github.com/josevalim and "Jonas Grimfelt":http://github.com/grimen and over 40 other contributors.
564
576
 
565
577
  @git shortlog -n -s --no-merges@
566
578
 
data/lib/formtastic.rb CHANGED
@@ -524,9 +524,9 @@ module Formtastic #:nodoc:
524
524
  raise ArgumentError, 'You gave :for option with a block to inputs method, ' <<
525
525
  'but the block does not accept any argument.' if block.arity <= 0
526
526
 
527
- proc { |f| return f.inputs(*args){ block.call(f) } }
527
+ lambda { |f| f.inputs(*args){ block.call(f) } }
528
528
  else
529
- proc { |f| return f.inputs(*args) }
529
+ lambda { |f| f.inputs(*args) }
530
530
  end
531
531
 
532
532
  fields_for_args = [options.delete(:for), options.delete(:for_options) || {}].flatten
@@ -1011,6 +1011,7 @@ module Formtastic #:nodoc:
1011
1011
  i18n_date_order = ::I18n.t(:order, :scope => [:date])
1012
1012
  i18n_date_order = nil unless i18n_date_order.is_a?(Array)
1013
1013
  inputs = options.delete(:order) || i18n_date_order || [:year, :month, :day]
1014
+ inputs = [] if options[:ignore_date]
1014
1015
  labels = options.delete(:labels) || {}
1015
1016
 
1016
1017
  time_inputs = [:hour, :minute]
@@ -1724,9 +1725,7 @@ module Formtastic #:nodoc:
1724
1725
  module SemanticFormHelper
1725
1726
  @@builder = ::Formtastic::SemanticFormBuilder
1726
1727
  mattr_accessor :builder
1727
-
1728
- @@default_field_error_proc = nil
1729
-
1728
+
1730
1729
  # Override the default ActiveRecordHelper behaviour of wrapping the input.
1731
1730
  # This gets taken care of semantically by adding an error class to the LI tag
1732
1731
  # containing the input.
@@ -1736,13 +1735,13 @@ module Formtastic #:nodoc:
1736
1735
  end
1737
1736
 
1738
1737
  def with_custom_field_error_proc(&block)
1739
- @@default_field_error_proc = ::ActionView::Base.field_error_proc
1738
+ default_field_error_proc = ::ActionView::Base.field_error_proc
1740
1739
  ::ActionView::Base.field_error_proc = FIELD_ERROR_PROC
1741
- result = yield
1742
- ::ActionView::Base.field_error_proc = @@default_field_error_proc
1743
- result
1740
+ yield
1741
+ ensure
1742
+ ::ActionView::Base.field_error_proc = default_field_error_proc
1744
1743
  end
1745
-
1744
+
1746
1745
  [:form_for, :fields_for, :remote_form_for].each do |meth|
1747
1746
  module_eval <<-END_SRC, __FILE__, __LINE__ + 1
1748
1747
  def semantic_#{meth}(record_or_name_or_array, *args, &proc)
@@ -15,7 +15,27 @@ describe 'time input' do
15
15
  ::I18n.backend.reload!
16
16
  output_buffer.replace ''
17
17
  end
18
-
18
+
19
+ describe "with :ignore_date" do
20
+ before do
21
+ semantic_form_for(@new_post) do |builder|
22
+ concat(builder.input(:publish_at, :as => :time, :ignore_date => true))
23
+ end
24
+ end
25
+
26
+ it 'should not have an input for day, month and year' do
27
+ output_buffer.should_not have_tag('#post_publish_at_1i')
28
+ output_buffer.should_not have_tag('#post_publish_at_2i')
29
+ output_buffer.should_not have_tag('#post_publish_at_3i')
30
+ end
31
+
32
+ it 'should have an input for hour and minute' do
33
+ output_buffer.should have_tag('#post_publish_at_4i')
34
+ output_buffer.should have_tag('#post_publish_at_5i')
35
+ end
36
+
37
+ end
38
+
19
39
  describe "without seconds" do
20
40
  before do
21
41
  semantic_form_for(@new_post) do |builder|
data/spec/inputs_spec.rb CHANGED
@@ -88,6 +88,24 @@ describe 'SemanticFormBuilder#inputs' do
88
88
 
89
89
  end
90
90
 
91
+ describe "as a symbol representing a has_many association name" do
92
+ before do
93
+ @new_post.stub!(:authors).and_return([@bob, @fred])
94
+ @new_post.stub!(:authors_attributes=)
95
+ end
96
+
97
+ it 'should nest the inputs with a name input for each item' do
98
+ semantic_form_for(@new_post) do |post|
99
+ post.inputs :for => :authors do |author|
100
+ concat(author.input(:login))
101
+ end
102
+ end
103
+
104
+ output_buffer.should have_tag("form input[@name='post[authors_attributes][0][login]']")
105
+ output_buffer.should have_tag("form input[@name='post[authors_attributes][1][login]']")
106
+ end
107
+ end
108
+
91
109
  describe 'as an array containing the a symbole for the association name and the associated object' do
92
110
 
93
111
  it 'should nest the inputs with an _attributes suffix on the association name' do
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 1
7
7
  - 0
8
8
  - 0
9
- - beta2
10
- version: 1.0.0.beta2
9
+ - beta3
10
+ version: 1.0.0.beta3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin French
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-21 00:00:00 +10:00
18
+ date: 2010-07-29 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency