justinfrench-formtastic 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/formtastic.rb +7 -2
- data/spec/formtastic_spec.rb +39 -8
- metadata +4 -3
data/lib/formtastic.rb
CHANGED
@@ -442,7 +442,8 @@ module Formtastic #:nodoc:
|
|
442
442
|
object_name = @object_name.to_s.send(@@label_str_method)
|
443
443
|
end
|
444
444
|
|
445
|
-
I18n.t(prefix.downcase, :default => prefix, :scope => [:formtastic])
|
445
|
+
button_text = I18n.t(prefix.downcase, :default => prefix, :scope => [:formtastic])
|
446
|
+
"#{button_text} #{object_name}"
|
446
447
|
end
|
447
448
|
|
448
449
|
# Determins if the attribute (eg :title) should be considered required or not.
|
@@ -979,6 +980,9 @@ module Formtastic #:nodoc:
|
|
979
980
|
# 'Task #3' and so on.
|
980
981
|
#
|
981
982
|
def field_set_and_list_wrapping(html_options, contents='', &block) #:nodoc:
|
983
|
+
html_options[:name] ||= html_options.delete(:title)
|
984
|
+
html_options[:name] = localized_attribute_string(html_options[:name], html_options[:name], :title) if html_options[:name].is_a?(Symbol)
|
985
|
+
|
982
986
|
legend = html_options.delete(:name).to_s
|
983
987
|
legend %= parent_child_index(html_options[:parent]) if html_options[:parent]
|
984
988
|
legend = template.content_tag(:legend, template.content_tag(:span, legend)) unless legend.blank?
|
@@ -1213,7 +1217,8 @@ module Formtastic #:nodoc:
|
|
1213
1217
|
if attr_value.is_a?(String)
|
1214
1218
|
attr_value
|
1215
1219
|
else
|
1216
|
-
use_i18n = attr_value.nil? ? @@i18n_lookups_by_default : attr_value
|
1220
|
+
use_i18n = attr_value.nil? ? @@i18n_lookups_by_default : (attr_value != false)
|
1221
|
+
|
1217
1222
|
if use_i18n
|
1218
1223
|
model_name = @object.class.name.underscore
|
1219
1224
|
action_name = template.params[:action].to_s rescue ''
|
data/spec/formtastic_spec.rb
CHANGED
@@ -2574,18 +2574,49 @@ describe 'Formtastic' do
|
|
2574
2574
|
end
|
2575
2575
|
end
|
2576
2576
|
|
2577
|
-
describe 'when a :name option is provided' do
|
2578
|
-
|
2579
|
-
|
2580
|
-
|
2581
|
-
|
2582
|
-
|
2577
|
+
describe 'when a :name or :title option is provided' do
|
2578
|
+
describe 'and is a string' do
|
2579
|
+
before do
|
2580
|
+
@legend_text = "Advanced options"
|
2581
|
+
@legend_text_using_title = "Advanced options 2"
|
2582
|
+
semantic_form_for(@new_post) do |builder|
|
2583
|
+
builder.inputs :name => @legend_text do
|
2584
|
+
end
|
2585
|
+
builder.inputs :title => @legend_text_using_title do
|
2586
|
+
end
|
2583
2587
|
end
|
2584
2588
|
end
|
2589
|
+
|
2590
|
+
it 'should render a fieldset with a legend inside the form' do
|
2591
|
+
output_buffer.should have_tag("form fieldset legend", /#{@legend_text}/)
|
2592
|
+
output_buffer.should have_tag("form fieldset legend", /#{@legend_text_using_title}/)
|
2593
|
+
end
|
2585
2594
|
end
|
2595
|
+
|
2596
|
+
describe 'and is a symbol' do
|
2597
|
+
before do
|
2598
|
+
@localized_legend_text = "Localized advanced options"
|
2599
|
+
@localized_legend_text_using_title = "Localized advanced options 2"
|
2600
|
+
I18n.backend.store_translations :en, :formtastic => {
|
2601
|
+
:titles => {
|
2602
|
+
:post => {
|
2603
|
+
:advanced_options => @localized_legend_text,
|
2604
|
+
:advanced_options_2 => @localized_legend_text_using_title
|
2605
|
+
}
|
2606
|
+
}
|
2607
|
+
}
|
2608
|
+
semantic_form_for(@new_post) do |builder|
|
2609
|
+
builder.inputs :name => :advanced_options do
|
2610
|
+
end
|
2611
|
+
builder.inputs :title => :advanced_options_2 do
|
2612
|
+
end
|
2613
|
+
end
|
2614
|
+
end
|
2586
2615
|
|
2587
|
-
|
2588
|
-
|
2616
|
+
it 'should render a fieldset with a localized legend inside the form' do
|
2617
|
+
output_buffer.should have_tag("form fieldset legend", /#{@localized_legend_text}/)
|
2618
|
+
output_buffer.should have_tag("form fieldset legend", /#{@localized_legend_text_using_title}/)
|
2619
|
+
end
|
2589
2620
|
end
|
2590
2621
|
end
|
2591
2622
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: justinfrench-formtastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin French
|
@@ -9,7 +9,7 @@ autorequire: formtastic
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-10 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- spec/test_helper.rb
|
37
37
|
has_rdoc: false
|
38
38
|
homepage: http://github.com/justinfrench/formtastic/tree/master
|
39
|
+
licenses:
|
39
40
|
post_install_message:
|
40
41
|
rdoc_options:
|
41
42
|
- --charset=UTF-8
|
@@ -56,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
57
|
requirements: []
|
57
58
|
|
58
59
|
rubyforge_project:
|
59
|
-
rubygems_version: 1.
|
60
|
+
rubygems_version: 1.3.5
|
60
61
|
signing_key:
|
61
62
|
specification_version: 3
|
62
63
|
summary: A Rails form builder plugin/gem with semantically rich and accessible markup
|