formtastic 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +26 -1
- data/lib/formtastic.rb +11 -38
- metadata +4 -4
data/README.textile
CHANGED
@@ -634,12 +634,37 @@ h2. Compatibility
|
|
634
634
|
|
635
635
|
h2. How to contribute
|
636
636
|
|
637
|
-
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
|
637
|
+
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 a pull request for your changes to be discussed and reviewed.
|
638
638
|
|
639
639
|
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.
|
640
640
|
|
641
641
|
For significant changes, you may wish to discuss your idea on the Formtastic Google group before coding to ensure that your change is likely to be accepted. Formtastic relies heavily on i18n, so if you're unsure of the impact this has on your changes, please discuss them with the group.
|
642
642
|
|
643
|
+
See below for installation of a development environment.
|
644
|
+
|
645
|
+
|
646
|
+
h2. Development Environment
|
647
|
+
|
648
|
+
We currently support both Rails 2 and Rails 3, under Ruby 1.8.7-ish (and 1.9.2-ish). That means, at a bare minimum, you'll want to set-up two rvm gemsets to run your specs against. So, fork the project on Github, clone it, make some gemsets, run bundler, run your specs and then finally set-up an .rvmrc file that specifies Rails 3 as your default gemset and cd back into that directory to load in the .rvmrc file. Something like this:
|
649
|
+
|
650
|
+
<pre>
|
651
|
+
$ cd ~/code/formtastic
|
652
|
+
$ rvm gemset create formtastic-rails3
|
653
|
+
$ rvm gemset use formtastic-rails3
|
654
|
+
$ gem install bundler
|
655
|
+
$ bundle install
|
656
|
+
$ rake spec
|
657
|
+
$ rm Gemfile.lock
|
658
|
+
$ rvm gemset create formtastic-rails2
|
659
|
+
$ rvm gemset use formtastic-rails2
|
660
|
+
$ gem install bundler
|
661
|
+
$ RAILS_2=true bundle install
|
662
|
+
$ rake spec
|
663
|
+
$ touch .rvmrc
|
664
|
+
$ echo "rvm gemset use formtastic-rails-3" > .rvmrc
|
665
|
+
$ cd ~/code/formtastic
|
666
|
+
</pre>
|
667
|
+
|
643
668
|
|
644
669
|
h2. Maintainers & Contributors
|
645
670
|
|
data/lib/formtastic.rb
CHANGED
@@ -295,11 +295,6 @@ module Formtastic #:nodoc:
|
|
295
295
|
end
|
296
296
|
end
|
297
297
|
|
298
|
-
def input_field_set(*args, &block)
|
299
|
-
::ActiveSupport::Deprecation.warn("input_field_set() is deprecated and will be removed in Formtastic 1.3 or later, use inputs() instead.", caller)
|
300
|
-
inputs(args, &block)
|
301
|
-
end
|
302
|
-
|
303
298
|
# Creates a fieldset and ol tag wrapping for form buttons / actions as list items.
|
304
299
|
# See inputs documentation for a full example. The fieldset's default class attriute
|
305
300
|
# is set to "buttons".
|
@@ -318,11 +313,6 @@ module Formtastic #:nodoc:
|
|
318
313
|
end
|
319
314
|
end
|
320
315
|
|
321
|
-
def button_field_set(*args, &block)
|
322
|
-
::ActiveSupport::Deprecation.warn("button_field_set() is deprecated and will be removed in Formtastic 1.3 or later, use inputs() instead.", caller)
|
323
|
-
buttons(args, &block)
|
324
|
-
end
|
325
|
-
|
326
316
|
# Creates a submit input tag with the value "Save [model name]" (for existing records) or
|
327
317
|
# "Create [model name]" (for new records) by default:
|
328
318
|
#
|
@@ -335,15 +325,11 @@ module Formtastic #:nodoc:
|
|
335
325
|
#
|
336
326
|
# And you can pass html atributes down to the input, with or without the button text:
|
337
327
|
#
|
338
|
-
# <%= form.commit_button "
|
339
|
-
# <%= form.commit_button :class => "pretty" %> => <input name="commit" type="submit" value="Save Post" class="pretty {create|update|submit}" />
|
340
|
-
#
|
328
|
+
# <%= form.commit_button :button_html => { :class => "pretty" } %> => <input name="commit" type="submit" value="Save Post" class="pretty {create|update|submit}" />
|
341
329
|
def commit_button(*args)
|
342
330
|
options = args.extract_options!
|
343
|
-
::ActiveSupport::Deprecation.warn(":class => 'whatever' is deprecated on commit button, use :wrapper_html => { :class => 'whatever' } instead.", caller) if options.key?(:class)
|
344
331
|
text = options.delete(:label) || args.shift
|
345
332
|
|
346
|
-
|
347
333
|
if @object && (@object.respond_to?(:persisted?) || @object.respond_to?(:new_record?))
|
348
334
|
if @object.respond_to?(:persisted?) # ActiveModel
|
349
335
|
key = @object.persisted? ? :update : :create
|
@@ -374,9 +360,9 @@ module Formtastic #:nodoc:
|
|
374
360
|
button_html = options.delete(:button_html) || {}
|
375
361
|
button_html.merge!(:class => [button_html[:class], key].compact.join(' '))
|
376
362
|
|
377
|
-
wrapper_html_class = ['commit'
|
363
|
+
wrapper_html_class = ['commit'] # TODO: Add class reflecting on form action.
|
378
364
|
wrapper_html = options.delete(:wrapper_html) || {}
|
379
|
-
wrapper_html[:class] = (wrapper_html_class << wrapper_html[:class]
|
365
|
+
wrapper_html[:class] = (wrapper_html_class << wrapper_html[:class]).flatten.compact.join(' ')
|
380
366
|
|
381
367
|
accesskey = (options.delete(:accesskey) || self.class.default_commit_button_accesskey) unless button_html.has_key?(:accesskey)
|
382
368
|
button_html = button_html.merge(:accesskey => accesskey) if accesskey
|
@@ -594,7 +580,7 @@ module Formtastic #:nodoc:
|
|
594
580
|
#
|
595
581
|
def strip_formtastic_options(options) #:nodoc:
|
596
582
|
options.except(:value_method, :label_method, :collection, :required, :label,
|
597
|
-
:as, :hint, :input_html, :label_html, :value_as_class, :find_options)
|
583
|
+
:as, :hint, :input_html, :label_html, :value_as_class, :find_options, :class)
|
598
584
|
end
|
599
585
|
|
600
586
|
# Determins if the attribute (eg :title) should be considered required or not.
|
@@ -631,6 +617,8 @@ module Formtastic #:nodoc:
|
|
631
617
|
|
632
618
|
# Determines whether the given options evaluate to true
|
633
619
|
def options_require_validation?(options) #nodoc
|
620
|
+
allow_blank = options[:allow_blank]
|
621
|
+
return !allow_blank unless allow_blank.nil?
|
634
622
|
if_condition = !options[:if].nil?
|
635
623
|
condition = if_condition ? options[:if] : options[:unless]
|
636
624
|
|
@@ -818,12 +806,7 @@ module Formtastic #:nodoc:
|
|
818
806
|
if reflection && [ :has_many, :has_and_belongs_to_many ].include?(reflection.macro)
|
819
807
|
html_options[:multiple] = true if html_options[:multiple].nil?
|
820
808
|
html_options[:size] ||= 5
|
821
|
-
|
822
|
-
if html_options[:multiple]
|
823
|
-
options[:include_blank] = false
|
824
|
-
else
|
825
|
-
options[:include_blank] ||= false
|
826
|
-
end
|
809
|
+
options[:include_blank] ||= false
|
827
810
|
end
|
828
811
|
options = set_include_blank(options)
|
829
812
|
input_name = generate_association_input_name(method)
|
@@ -855,11 +838,6 @@ module Formtastic #:nodoc:
|
|
855
838
|
self.label(method, label_options) << select_html
|
856
839
|
end
|
857
840
|
|
858
|
-
def boolean_select_input(method, options)
|
859
|
-
::ActiveSupport::Deprecation.warn(":as => :boolean_select is deprecated and will be removed in Formtastic 1.3 or later. Use :as => :select instead.", caller)
|
860
|
-
select_input(method, options)
|
861
|
-
end
|
862
|
-
|
863
841
|
# Outputs a timezone select input as Rails' time_zone_select helper. You
|
864
842
|
# can give priority zones as option.
|
865
843
|
#
|
@@ -963,11 +941,6 @@ module Formtastic #:nodoc:
|
|
963
941
|
)
|
964
942
|
end
|
965
943
|
|
966
|
-
def boolean_radio_input(method, options)
|
967
|
-
::ActiveSupport::Deprecation.warn(":as => :boolean_radio is deprecated and will be removed in Formtastic 1.3 or later. Use :as => :radio instead.", caller)
|
968
|
-
radio_input(method, options)
|
969
|
-
end
|
970
|
-
|
971
944
|
# Outputs a fieldset with a legend for the method label, and a ordered list (ol) of list
|
972
945
|
# items (li), one for each fragment for the date (year, month, day). Each li contains a label
|
973
946
|
# (eg "Year") and a select box. Overwriting the label is possible by adding the :labels option.
|
@@ -1270,20 +1243,20 @@ module Formtastic #:nodoc:
|
|
1270
1243
|
# to the column name (method name) and can be altered with the :label option.
|
1271
1244
|
# :checked_value and :unchecked_value options are also available.
|
1272
1245
|
def boolean_input(method, options)
|
1273
|
-
html_options
|
1246
|
+
html_options = options.delete(:input_html) || {}
|
1274
1247
|
checked_value = options.delete(:checked_value) || '1'
|
1275
1248
|
unchecked_value = options.delete(:unchecked_value) || '0'
|
1276
1249
|
|
1277
|
-
|
1250
|
+
html_options[:id] = html_options[:id] || generate_html_id(method, "")
|
1278
1251
|
input = template.check_box_tag(
|
1279
1252
|
"#{@object_name}[#{method}]",
|
1280
1253
|
checked_value,
|
1281
1254
|
(@object && @object.send(:"#{method}")),
|
1282
|
-
|
1255
|
+
html_options
|
1283
1256
|
)
|
1284
1257
|
|
1285
1258
|
options = options_for_label(options)
|
1286
|
-
options[:for] ||=
|
1259
|
+
options[:for] ||= html_options[:id]
|
1287
1260
|
|
1288
1261
|
# the label() method will insert this nested input into the label at the last minute
|
1289
1262
|
options[:label_prefix_for_nested_input] = input
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formtastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 2
|
10
|
+
version: 1.2.2
|
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-11-
|
18
|
+
date: 2010-11-29 00:00:00 +11:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|