Browse files

Merge branch 'master' into 1.2-stable

Conflicts:
	CHANGELOG
  • Loading branch information...
2 parents 8a31e6f + f53e74a commit 07e850357457f71e1a7a3db0d80544ca1c45379e @justinfrench committed Feb 9, 2011
View
39 CHANGELOG
@@ -1,7 +1,15 @@
+1.2.4.beta (unreleased)
+
+* Changed :boolean inputs to use Rails' check_box_checked? instead of our own logic
+* Changed developer instructions in README
+* Fixed :boolean inputs to disable the included hidden input when disabling the actual checkbox
+* Fixed that Formtastic was making changes to the options hash directly instead of on a duplicate, causing problems for those trying to reuse options on multiple inputs in the view
+* Fixed that tiny scroll bars were appearing on legends in date/time/radio/cbheckboxes fielsets (GH-477)
+
1.2.3
-* Fixed documentation typos
* Changed i18n gem dependency from ">= 0.4.0" to "~> 0.4" to work with apps that require i18n 0.5
+* Fixed documentation typos
1.2.3.beta
@@ -16,6 +24,35 @@
* Added Rails 3 compatible form generator templates in addition to existing Rails 2 support
* Added reflection on allow_blank option when determining the 'required' status of an input
+850bf1d .dup options hash before we fiddle with it so that the same hash can be re-used in views between inputs (GH-474)
+2d69c23 Merge branch 'class_attribute_fix' into 1.2-stable
+1b12feb Stylistic change to remove self. prefix on method calls
+0a8fe2d Use class_attribute configuration instance methods
+58a91b5 use class_attribute as the priority over class_inheritable_accesssor
+88c5552 adding a note/warning about subclassing in the initializer template
+8bfc66b CHANGELOG catch-up
+3fb94d1 use class_attribute instead of class_inheritable_accessor if defined
+65e7e2d Rails 2 & 3 compatible form generator templates (GH-472):
+029f758 Rails 2 & 3 compatible form generator templates (GH-472):
+772bf40 Add missing </pre> to README.
+3ba4485 Add missing </pre> to README.
+6baeac9 Merge branch 'vijaydev-master' into 1.2-stable
+e1e1b81 Merge branch 'master' of https://github.com/vijaydev/formtastic into vijaydev-master
+e6aba23 corrected documentation on how to override a value
+cd3b49c corrected documentation on how to override a value
+5a73707 Fixes Issue #468 - https://github.com/justinfrench/formtastic/issues/#issue/468 - where the directories config/initializers and public/stylesheets are removed on running t
+b6e580d fixing rails 2 development instruction
+533c086 added a section to the README on getting a dev environment up and running
+d952753 Remove unnecessary gem method, now handled by bundler
+249dba1 Add bundler for easier development setup Add support to switch between rails versions in dev
+1aecc63 Input spec failing in 2.3.x because form was in output_buffer twice...
+4fcd1e8 Use real object to get specs passing in ruby 192
+9b00e07 reflect on allow_blank option to determine required status
+8f75fc7 input_html should be passed to checkbox_tag
+aac0564 removed a bunch of deprecated methods and options
+
+
+* Fixed an issue when formtastic fails to determine if a checkbox is checked with custom checked and unchecked values (thanks to Eugene Bolshakov)
1.2.2
View
8 lib/formtastic.rb
@@ -286,7 +286,7 @@ def inputs(*args, &block)
html_options = args.extract_options!
html_options[:class] ||= "inputs"
html_options[:name] = title
-
+
if html_options[:for] # Nested form
inputs_for_nested_attributes(*(args << html_options), &block)
elsif block_given?
@@ -569,7 +569,6 @@ def inputs_for_nested_attributes(*args, &block) #:nodoc:
fields_for_block = if block_given?
raise ArgumentError, 'You gave :for option with a block to inputs method, ' <<
'but the block does not accept any argument.' if block.arity <= 0
-
lambda do |f|
contents = f.inputs(*args){ block.call(f) }
template.concat(contents) if ::Formtastic::Util.rails3?
@@ -1257,12 +1256,13 @@ def boolean_input(method, options)
html_options = options.delete(:input_html) || {}
checked_value = options.delete(:checked_value) || '1'
unchecked_value = options.delete(:unchecked_value) || '0'
+ checked = @object && ActionView::Helpers::InstanceTag.check_box_checked?(@object.send(:"#{method}"), checked_value)
html_options[:id] = html_options[:id] || generate_html_id(method, "")
input = template.check_box_tag(
"#{@object_name}[#{method}]",
checked_value,
- (@object && @object.send(:"#{method}")),
+ checked,
html_options
)
@@ -1356,7 +1356,7 @@ def field_set_and_list_wrapping(*args, &block) #:nodoc:
contents = args.last.is_a?(::Hash) ? '' : args.pop.flatten
html_options = args.extract_options!
- legend = html_options.delete(:name).to_s
+ legend = html_options.dup.delete(:name).to_s
legend %= parent_child_index(html_options[:parent]) if html_options[:parent]
legend = template.content_tag(:legend, template.content_tag(:span, Formtastic::Util.html_safe(legend))) unless legend.blank?
View
2 lib/generators/templates/formtastic.css
@@ -56,7 +56,7 @@ form.formtastic fieldset > ol > li > li label input { line-height:100%; vertical
/* NESTED FIELDSETS AND LEGENDS (radio, check boxes and date/time inputs use nested fieldsets)
--------------------------------------------------------------------------------------------------*/
form.formtastic fieldset > ol > li fieldset { position:relative; }
-form.formtastic fieldset > ol > li fieldset legend { position:absolute; width:95%; padding-top:0.1em; left: 0px; }
+form.formtastic fieldset > ol > li fieldset legend { position:absolute; width:95%; left: 0px; }
form.formtastic fieldset > ol > li fieldset legend span { position:absolute; }
form.formtastic fieldset > ol > li fieldset legend.label label { position:absolute; }
form.formtastic fieldset > ol > li fieldset ol { float:left; width:74%; margin:0; padding:0 0 0 25%; }
View
22 spec/inputs/boolean_input_spec.rb
@@ -83,6 +83,28 @@
output_buffer.should_not have_tag('form li label input[@type="hidden"]') # invalid HTML5
end
+ it 'should generate a checked input if object.method returns checked value' do
+ @new_post.stub!(:allow_comments).and_return('yes')
+
+ form = semantic_form_for(@new_post) do |builder|
+ concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'yes', :unchecked_value => 'no'))
+ end
+
+ output_buffer.concat(form) if Formtastic::Util.rails3?
+ output_buffer.should have_tag('form li label input[@type="checkbox"][@value="yes"][@checked="checked"]')
+ end
+
+ it 'should not generate a checked input if object.method returns unchecked value' do
+ @new_post.stub!(:allow_comments).and_return('no')
+
+ form = semantic_form_for(@new_post) do |builder|
+ concat(builder.input(:allow_comments, :as => :boolean, :checked_value => 'yes', :unchecked_value => 'no'))
+ end
+
+ output_buffer.concat(form) if Formtastic::Util.rails3?
+ output_buffer.should have_tag('form li label input[@type="checkbox"][@value="yes"]:not([@checked])')
+ end
+
it 'should generate a label and a checkbox even if no object is given' do
form = semantic_form_for(:project, :url => 'http://test.host') do |builder|
concat(builder.input(:allow_comments, :as => :boolean))
View
1 spec/inputs/check_boxes_input_spec.rb
@@ -231,6 +231,7 @@
it "should have one item disabled; the specified one" do
output_buffer.concat(@form) if Formtastic::Util.rails3?
+ output_buffer.should have_tag("form li fieldset ol li input[@type='hidden'][@disabled='disabled']", :count => 1)
output_buffer.should have_tag("form li fieldset ol li label input[@disabled='disabled']", :count => 1)
output_buffer.should have_tag("form li fieldset ol li label[@for='post_author_ids_#{@fred.id}']", /fred/i)
output_buffer.should have_tag("form li fieldset ol li label input[@disabled='disabled'][@value='#{@fred.id}']")
View
6 spec/inputs_spec.rb
@@ -120,14 +120,16 @@
@new_post.stub!(:authors_attributes=)
end
- it 'should nest the inputs with a name input for each item' do
+ it 'should nest the inputs with a fieldset, legend and :name input for each item' do
form = semantic_form_for(@new_post) do |post|
- post.inputs :for => :authors do |author|
+ post.inputs :for => :authors, :name => '%i' do |author|
concat(author.input(:login))
end
end
output_buffer.concat(form) if Formtastic::Util.rails3?
+ output_buffer.should have_tag("form fieldset.inputs", :count => 2)
+ output_buffer.should have_tag("form fieldset.inputs legend", :count => 2)
output_buffer.should have_tag("form input[@name='post[authors_attributes][0][login]']")
output_buffer.should have_tag("form input[@name='post[authors_attributes][1][login]']")
end
View
6 spec/spec_helper.rb
@@ -307,12 +307,6 @@ def with_config(config_method_name, value, &block)
::Formtastic::SemanticFormBuilder.send(:"#{config_method_name}=", old_value)
end
- def with_deprecation_silenced(&block)
- ::ActiveSupport::Deprecation.silenced = true
- yield
- ::ActiveSupport::Deprecation.silenced = false
- end
-
end
::ActiveSupport::Deprecation.silenced = false
View
6 spec/support/deprecation.rb
@@ -0,0 +1,6 @@
+def with_deprecation_silenced(&block)
+ ::ActiveSupport::Deprecation.silence do
+ yield
+ end
+end
+
View
123 stylesheet_tests/basic_inputs.html
@@ -0,0 +1,123 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>index</title>
+ <link rel="stylesheet" href="../lib/generators/templates/formtastic.css" type="text/css">
+ <style>
+ body { font-family:helvetica, arial; }
+ </style>
+</head>
+<body>
+
+ <form class='formtastic'>
+ <fieldset>
+ <ol>
+
+ <li class="string">
+ <label>String</label>
+ <input type="text" value="value" size="5" maxlength="2">
+ </li>
+
+ <li class="url">
+ <label>URL</label>
+ <input type="url" value="value">
+ </li>
+
+ <li class="password">
+ <label>Password</label>
+ <input type="password" value="value">
+ </li>
+
+ <li class="numeric">
+ <label>Numeric</label>
+ <input type="numeric" value="value">
+ </li>
+
+ <li class="file">
+ <label>File</label>
+ <input type="file" value="value">
+ </li>
+
+ <li class="email">
+ <label>Email</label>
+ <input type="email" value="value">
+ </li>
+
+ <li class="phone">
+ <label>Phone</label>
+ <input type="phone" value="value">
+ </li>
+
+ <li class="search">
+ <label>Search</label>
+ <input type="search" value="value">
+ </li>
+
+ <li class="text">
+ <label>Text</label>
+ <textarea>value</textarea>
+ </li>
+
+ <li class="date">
+ <fieldset>
+ <legend class="label"><label>Date</label></legend>
+ <ol>
+ <li>
+ <label>Year</label>
+ <select>
+ <option>Foo</option>
+ </select>
+ </li>
+ <li>
+ <label>Month</label>
+ <select>
+ <option>Foo</option>
+ </select>
+ </li>
+ <li>
+ <label>Day</label>
+ <select>
+ <option>Foo</option>
+ </select>
+ </li>
+ </ol>
+ </fieldset>
+ </li>
+
+ <li class="radio">
+ <fieldset>
+ <legend class="label"><label>Radio</label></legend>
+ <ol>
+ <li>
+ <label><input type="radio"> Foo</label></label>
+ </li>
+ <li>
+ <label><input type="radio"> Bah</label></label>
+ </li>
+ </ol>
+ </fieldset>
+ </li>
+
+ <li class="check_boxes">
+ <fieldset>
+ <legend class="label"><label>Radio</label></legend>
+ <ol>
+ <li>
+ <label><input type="checkbox"> Foo</label></label>
+ </li>
+ <li>
+ <label><input type="checkbox"> Bah</label></label>
+ </li>
+ </ol>
+ </fieldset>
+ </li>
+
+ </ol>
+ </fieldset>
+ </form>
+
+</body>
+</html>

0 comments on commit 07e8503

Please sign in to comment.