nested_form_fields 0.7.8 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/lib/nested_form_fields.rb +6 -0
- data/lib/nested_form_fields/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 129eaaa576452be6947868888dbb854785529e65
|
4
|
+
data.tar.gz: e8580e4da7760a584c6048171112e55982683c9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 820f6d5e432d72232ca6ccd05b1a0623d3065ff491d3f3ef25b094ac39c85c661880dd0ef84bfb7a19dbcea4d6f035fc196f57ab4cb5daa635971a82106008c3
|
7
|
+
data.tar.gz: 11affd01bfcb4ef721af92817ad0132fa027d0d55afae542da5a226c36852915d481c455fd897137e75ec27722a8c00939738b11564ad49c4d91efd348e5b9ac
|
data/README.md
CHANGED
@@ -80,7 +80,7 @@ f.add_nested_fields_link :videos, 'Add another funtastic video', class: 'btn btn
|
|
80
80
|
You can supply a block to the `remove_nested_fields_link` and the `add_nested_fields_link` helpers, as you can with `link_to`:
|
81
81
|
|
82
82
|
```haml
|
83
|
-
= ff.remove_nested_fields_link
|
83
|
+
= ff.remove_nested_fields_link do
|
84
84
|
Remove me %span.icon-trash
|
85
85
|
```
|
86
86
|
|
@@ -141,8 +141,8 @@ def user_params
|
|
141
141
|
params.require(:user)
|
142
142
|
.permit(:name,:email,videos_attributes:[:video_title,:_destroy,:id])
|
143
143
|
# ^^^ ^^^ ^^^
|
144
|
-
# nested model attrs
|
145
|
-
# they will let you delete the nested model
|
144
|
+
# nested model attrs
|
145
|
+
# they will let you delete the nested model
|
146
146
|
end
|
147
147
|
```
|
148
148
|
|
@@ -190,11 +190,11 @@ $(document).on "fields_added.nested_form_fields", (event, param) ->
|
|
190
190
|
|
191
191
|
## Index replacement string
|
192
192
|
|
193
|
-
Sometimes your code needs to know what index it has when it is instantiated onto the page.
|
193
|
+
Sometimes your code needs to know what index it has when it is instantiated onto the page.
|
194
194
|
HTML data elements may need point to other form elements for instance. This is needed for integration
|
195
|
-
with rails3-jquery-autocomplete.
|
195
|
+
with rails3-jquery-autocomplete.
|
196
196
|
|
197
|
-
To enable string substitution with the current index use the magic string '
|
197
|
+
To enable string substitution with the current index use the magic string '\__nested_field_for_replace_with_index\__'.
|
198
198
|
|
199
199
|
## Contributing
|
200
200
|
|
data/lib/nested_form_fields.rb
CHANGED
@@ -73,6 +73,7 @@ module ActionView::Helpers
|
|
73
73
|
wrapper_options = options[:wrapper_options].clone || {}
|
74
74
|
if child._destroy == true
|
75
75
|
wrapper_options[:style] = wrapper_options[:style] ? wrapper_options[:style] + ';' + 'display:none' : 'display:none'
|
76
|
+
output << destroy_hidden_field(association_name, index)
|
76
77
|
end
|
77
78
|
output << nested_fields_wrapper(association_name, options[:wrapper_tag], options[:legend], wrapper_options) do
|
78
79
|
new_block = fields_for_nested_model("#{name}[#{options[:child_index] || nested_child_index(name)}]", child, options, block)
|
@@ -132,6 +133,11 @@ module ActionView::Helpers
|
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
136
|
+
def destroy_hidden_field(association_name, index)
|
137
|
+
@template.hidden_field "#{object_name}[#{association_name}_attributes][#{index}]",
|
138
|
+
:_destroy, value: 1
|
139
|
+
end
|
140
|
+
|
135
141
|
def add_default_classes_to_wrapper_options(association_name, wrapper_options)
|
136
142
|
default_classes = ["nested_fields", "nested_#{association_path(association_name)}"]
|
137
143
|
wrapper_options[:class] = wrapper_options[:class].is_a?(String) ? wrapper_options[:class].split(" ") : wrapper_options[:class].to_a
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nested_form_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.8'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nico Ritsche
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|