dynamic_fields_for_rails 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -7
- data/app/helpers/dynamic_fields_for_helper.rb +11 -3
- data/lib/dynamic_fields_for_rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8381f72a7b4a040ec6fa54efae00061444298d91
|
4
|
+
data.tar.gz: 44b718e8c67121a9c58a6516710f4aecde01e3f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87872c789074360034d4dee33965471b0be10c8d371b7da40f1c6873259a9c56f4893d2cff6575f24ded05a3c9b5ee8d130a94fa8ae9cc1f73c77c962309dcbe
|
7
|
+
data.tar.gz: a78a73e194b4e71402d914d0298f660a1883dde5067a7f9e9ce9e48b64f86874cf0abf8f7d6bf388ec0e8c3fd77474b4f4405aa740189a1f4a6428028d90e303
|
data/README.md
CHANGED
@@ -37,13 +37,14 @@ Create a partial for your nested resource called "_{nested_resoure}_fields.haml"
|
|
37
37
|
Add to the partial only the fields you want to edit like this:
|
38
38
|
|
39
39
|
```
|
40
|
-
|
41
|
-
= fields.
|
42
|
-
|
43
|
-
|
44
|
-
= fields.
|
45
|
-
|
46
|
-
|
40
|
+
.fields
|
41
|
+
= fields.label :field1
|
42
|
+
= fields.text_field :field1
|
43
|
+
|
44
|
+
= fields.label :field2
|
45
|
+
= fields.text_field :field2
|
46
|
+
|
47
|
+
= link_to_delete_fields fields, "Delete"
|
47
48
|
```
|
48
49
|
|
49
50
|
The "link_to_delete_fields" helper is a easy way to make the nested fields deletable. You can put whatever divs/fieldsets etc. around those fields to style them.
|
@@ -1,11 +1,19 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module DynamicFieldsForHelper
|
3
3
|
|
4
|
-
def link_to_add_fields(form, association,
|
4
|
+
def link_to_add_fields(form, association, options, &block)
|
5
|
+
partial = options[:partial] || nil
|
6
|
+
name = options[:name] || nil
|
7
|
+
css_classes = options[:class] || nil
|
8
|
+
|
5
9
|
new_object = form.object.send(association).klass.new
|
6
10
|
id = new_object.object_id
|
7
11
|
fields = form.fields_for(association, new_object, child_index: id) do |builder|
|
8
|
-
|
12
|
+
if partial
|
13
|
+
render("#{form.object.class.name.downcase.pluralize}/#{partial}", fields: builder)
|
14
|
+
else
|
15
|
+
render("#{form.object.class.name.downcase.pluralize}/#{association.to_s.singularize}_fields", fields: builder)
|
16
|
+
end
|
9
17
|
end
|
10
18
|
css_classes = css_classes(DynamicFieldsForRails.add_css_classes, css_classes)
|
11
19
|
if block_given?
|
@@ -35,4 +43,4 @@ module DynamicFieldsForHelper
|
|
35
43
|
style_class << css_class unless css_class.blank?
|
36
44
|
style_class.join(' ')
|
37
45
|
end
|
38
|
-
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_fields_for_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Klitzke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
version: '0'
|
167
167
|
requirements: []
|
168
168
|
rubyforge_project:
|
169
|
-
rubygems_version: 2.0.
|
169
|
+
rubygems_version: 2.0.14
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: Helper for nested forms with dynamic fields.
|