formtastic 1.2.3 → 1.2.4.beta2

Sign up to get free protection for your applications and to get access to all the features.
@@ -256,8 +256,8 @@ Customize HTML attributes for any input using the @:input_html@ option. Typicall
256
256
 
257
257
  <pre>
258
258
  <% semantic_form_for @post do |form| %>
259
- <%= form.input :title, :input_html => { :size => 60 } %>
260
- <%= form.input :body, :input_html => { :class => 'autogrow' } %>
259
+ <%= form.input :title, :input_html => { :cols => 10 } %>
260
+ <%= form.input :body, :input_html => { :class => 'autogrow', :rows => 10, :cols => 20, :maxlength => 10 } %>
261
261
  <%= form.input :created_at, :input_html => { :disabled => true } %>
262
262
  <%= form.buttons %>
263
263
  <% end %>
@@ -286,7 +286,7 @@ module Formtastic #:nodoc:
286
286
  html_options = args.extract_options!
287
287
  html_options[:class] ||= "inputs"
288
288
  html_options[:name] = title
289
-
289
+
290
290
  if html_options[:for] # Nested form
291
291
  inputs_for_nested_attributes(*(args << html_options), &block)
292
292
  elsif block_given?
@@ -569,7 +569,6 @@ module Formtastic #:nodoc:
569
569
  fields_for_block = if block_given?
570
570
  raise ArgumentError, 'You gave :for option with a block to inputs method, ' <<
571
571
  'but the block does not accept any argument.' if block.arity <= 0
572
-
573
572
  lambda do |f|
574
573
  contents = f.inputs(*args){ block.call(f) }
575
574
  template.concat(contents) if ::Formtastic::Util.rails3?
@@ -1257,12 +1256,13 @@ module Formtastic #:nodoc:
1257
1256
  html_options = options.delete(:input_html) || {}
1258
1257
  checked_value = options.delete(:checked_value) || '1'
1259
1258
  unchecked_value = options.delete(:unchecked_value) || '0'
1259
+ checked = @object && ActionView::Helpers::InstanceTag.check_box_checked?(@object.send(:"#{method}"), checked_value)
1260
1260
 
1261
1261
  html_options[:id] = html_options[:id] || generate_html_id(method, "")
1262
1262
  input = template.check_box_tag(
1263
1263
  "#{@object_name}[#{method}]",
1264
1264
  checked_value,
1265
- (@object && @object.send(:"#{method}")),
1265
+ checked,
1266
1266
  html_options
1267
1267
  )
1268
1268
 
@@ -1272,7 +1272,7 @@ module Formtastic #:nodoc:
1272
1272
  # the label() method will insert this nested input into the label at the last minute
1273
1273
  options[:label_prefix_for_nested_input] = input
1274
1274
 
1275
- template.hidden_field_tag("#{@object_name}[#{method}]", unchecked_value, :id => nil) << label(method, options)
1275
+ template.hidden_field_tag((html_options[:name] || "#{@object_name}[#{method}]"), unchecked_value, :id => nil, :disabled => html_options[:disabled]) << label(method, options)
1276
1276
  end
1277
1277
 
1278
1278
  # Generates an input for the given method using the type supplied with :as.
@@ -1356,7 +1356,7 @@ module Formtastic #:nodoc:
1356
1356
  contents = args.last.is_a?(::Hash) ? '' : args.pop.flatten
1357
1357
  html_options = args.extract_options!
1358
1358
 
1359
- legend = html_options.delete(:name).to_s
1359
+ legend = html_options.dup.delete(:name).to_s
1360
1360
  legend %= parent_child_index(html_options[:parent]) if html_options[:parent]
1361
1361
  legend = template.content_tag(:legend, template.content_tag(:span, Formtastic::Util.html_safe(legend))) unless legend.blank?
1362
1362
 
@@ -1620,6 +1620,8 @@ module Formtastic #:nodoc:
1620
1620
  if reflection = reflection_for(method)
1621
1621
  if [:has_and_belongs_to_many, :has_many].include?(reflection.macro)
1622
1622
  "#{method.to_s.singularize}_ids"
1623
+ elsif reflection.respond_to? :foreign_key
1624
+ reflection.foreign_key
1623
1625
  else
1624
1626
  reflection.options[:foreign_key] || "#{method}_id"
1625
1627
  end
@@ -30,7 +30,7 @@ form.formtastic ul.errors li { padding:0; border:none; display:list-item; }
30
30
 
31
31
  /* FIELDSETS & LISTS
32
32
  --------------------------------------------------------------------------------------------------*/
33
- form.formtastic fieldset { overflow:auto; } /* clearing contained floats */
33
+ form.formtastic fieldset { overflow:hidden; } /* clearing contained floats */
34
34
  form.formtastic fieldset.inputs { }
35
35
  form.formtastic fieldset.buttons { padding-left:25%; }
36
36
  form.formtastic fieldset ol { }
@@ -39,7 +39,7 @@ form.formtastic fieldset.buttons li { float:left; padding-right:0.5em; }
39
39
  /* INPUT LIs
40
40
  --------------------------------------------------------------------------------------------------*/
41
41
  form.formtastic fieldset > ol > li { padding:0.5em 0; margin-top:-0.5em; margin-bottom:1em; } /* padding and negative margin juggling is for Firefox */
42
- form.formtastic fieldset > ol > li { overflow:auto; } /* clearing contained floats */
42
+ form.formtastic fieldset > ol > li { overflow:hidden; } /* clearing contained floats */
43
43
 
44
44
  form.formtastic fieldset > ol > li.required { }
45
45
  form.formtastic fieldset > ol > li.optional { }
@@ -56,7 +56,7 @@ form.formtastic fieldset > ol > li > li label input { line-height:100%; vertical
56
56
  /* NESTED FIELDSETS AND LEGENDS (radio, check boxes and date/time inputs use nested fieldsets)
57
57
  --------------------------------------------------------------------------------------------------*/
58
58
  form.formtastic fieldset > ol > li fieldset { position:relative; }
59
- form.formtastic fieldset > ol > li fieldset legend { position:absolute; width:95%; padding-top:0.1em; left: 0px; }
59
+ form.formtastic fieldset > ol > li fieldset legend { position:absolute; width:95%; left: 0px; }
60
60
  form.formtastic fieldset > ol > li fieldset legend span { position:absolute; }
61
61
  form.formtastic fieldset > ol > li fieldset legend.label label { position:absolute; }
62
62
  form.formtastic fieldset > ol > li fieldset ol { float:left; width:74%; margin:0; padding:0 0 0 25%; }
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formtastic
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
4
+ hash: -1848230054
5
+ prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 3
10
- version: 1.2.3
9
+ - 4
10
+ - beta2
11
+ version: 1.2.4.beta2
11
12
  platform: ruby
12
13
  authors:
13
14
  - Justin French
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-01-07 00:00:00 +11:00
19
+ date: 2011-05-16 00:00:00 +10:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency