nofxx-formtastic 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/formtastic.rb +10 -8
- metadata +7 -9
data/lib/formtastic.rb
CHANGED
@@ -342,19 +342,21 @@ module Formtastic #:nodoc:
|
|
342
342
|
variable = "formtastic_next_#{associated_name}_id"
|
343
343
|
|
344
344
|
opts.symbolize_keys!
|
345
|
-
|
346
345
|
partial = opts.delete(:partial) || associated_name
|
347
346
|
container = opts.delete(:expression) || "'#{opts.delete(:container) || '#'+associated_name.pluralize}'"
|
348
347
|
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
348
|
+
form = self.render_associated_form(object, :partial => partial)
|
349
|
+
form.gsub!(/attributes_(\d+)/, '__idx__')
|
350
|
+
form.gsub!(/\[(\d+)\]/, '__idxx__')
|
351
|
+
|
352
|
+
function = "if (typeof #{variable} == 'undefined') #{variable} = #{$1};
|
353
|
+
$(#{container}).append($.template(#{form.to_json}.replace(/__idx__/g, \"attributes_\" +
|
354
|
+
#{variable}).replace(/__idxx__/g, \"[\" + #{variable}++ + \"]\")))"
|
353
355
|
|
354
356
|
template.link_to_function(name, function, opts)
|
355
357
|
end
|
356
358
|
|
357
|
-
|
359
|
+
# Render associated form
|
358
360
|
def render_associated_form(associated, opts = {})
|
359
361
|
associated = associated.is_a?(Array) ? associated : [associated] # preserve association proxy if this is one
|
360
362
|
|
@@ -369,7 +371,7 @@ module Formtastic #:nodoc:
|
|
369
371
|
|
370
372
|
output = associated.map do |element|
|
371
373
|
fields_for(association_name(name), element, (opts[:fields_for] || {}).merge(:name => name)) do |f|
|
372
|
-
template.render({:partial => "#{partial}", :locals => {local_assign_name.to_sym =>
|
374
|
+
template.render({:partial => "#{partial}", :locals => {local_assign_name.to_sym => element, :f => f}.merge(opts[:locals] || {})}.merge(opts[:render] || {}))
|
373
375
|
end
|
374
376
|
end
|
375
377
|
output.join
|
@@ -383,7 +385,7 @@ module Formtastic #:nodoc:
|
|
383
385
|
end
|
384
386
|
|
385
387
|
def extract_option_or_class_name(hash, option, object)
|
386
|
-
(hash.delete(option) || object.class.name.split('::').last.underscore)
|
388
|
+
(hash.delete(option) || object.class.name.split('::').last.underscore)
|
387
389
|
end
|
388
390
|
# End attribute_fu magic #
|
389
391
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nofxx-formtastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
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-04-
|
12
|
+
date: 2009-04-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -25,12 +25,10 @@ files:
|
|
25
25
|
- MIT-LICENSE
|
26
26
|
- README.textile
|
27
27
|
- Rakefile
|
28
|
-
- rails/init.rb
|
29
28
|
- lib/formtastic.rb
|
30
|
-
- lib/justin_french
|
31
29
|
- lib/justin_french/formtastic.rb
|
32
|
-
- lib/locale
|
33
30
|
- lib/locale/en.yml
|
31
|
+
- rails/init.rb
|
34
32
|
- spec/formtastic_spec.rb
|
35
33
|
- spec/spec.opts
|
36
34
|
- spec/test_helper.rb
|
@@ -38,7 +36,6 @@ has_rdoc: true
|
|
38
36
|
homepage: http://github.com/justinfrench/formtastic/tree/master
|
39
37
|
post_install_message:
|
40
38
|
rdoc_options:
|
41
|
-
- --inline-source
|
42
39
|
- --charset=UTF-8
|
43
40
|
require_paths:
|
44
41
|
- lib
|
@@ -59,7 +56,8 @@ requirements: []
|
|
59
56
|
rubyforge_project:
|
60
57
|
rubygems_version: 1.2.0
|
61
58
|
signing_key:
|
62
|
-
specification_version:
|
59
|
+
specification_version: 3
|
63
60
|
summary: A Rails form builder plugin/gem with semantically rich and accessible markup
|
64
|
-
test_files:
|
65
|
-
|
61
|
+
test_files:
|
62
|
+
- spec/formtastic_spec.rb
|
63
|
+
- spec/test_helper.rb
|