make 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/make/form.rb +28 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13d4a9d819e59a3736ad889e48f6b64093215cd5
|
4
|
+
data.tar.gz: 859571be189a93332bafd94f477eb6efe811bc2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5bd0d1e3ef3389855bff0dbb53113c48033d26df40bda17674cb2c4009b28686363624fe2ea4ddbe0e627eab1565bb370b18c321e8a2f961a6ba54a86687bff
|
7
|
+
data.tar.gz: 6d5db6e0b775102a84935cd1743748d0f781e0595272e5b63adaa81cb38ef5aad2eb7031ef99bc1888a4345eb3c8da14f5db51cfcc4fa1a44c5191f2861830c3
|
data/lib/make/form.rb
CHANGED
@@ -32,6 +32,13 @@ class Form
|
|
32
32
|
@formAction = url
|
33
33
|
return self
|
34
34
|
end
|
35
|
+
# hide array of specific fields that should not be submitted through
|
36
|
+
def hide columns
|
37
|
+
columns.each do |col|
|
38
|
+
@potential_keys_to_ignore.push(col.to_s)
|
39
|
+
end
|
40
|
+
return self
|
41
|
+
end
|
35
42
|
# Change form class
|
36
43
|
def class myClass
|
37
44
|
@formClass = myClass
|
@@ -74,6 +81,27 @@ class Form
|
|
74
81
|
@formMiddle.push(input)
|
75
82
|
return self
|
76
83
|
end
|
84
|
+
# Similar to select, but association assumed and specific associated column name can be selected
|
85
|
+
def assoc column, assocColumn, array='all'
|
86
|
+
columnName = column.titleize
|
87
|
+
input = "\n\t<label>" + columnName + "\n\t</label>\n\t<select name=\"" + @modelName + "[" + column + "]\">"
|
88
|
+
assocModel = column[0...-3].capitalize.constantize
|
89
|
+
array = assocModel.distinct.count('id')
|
90
|
+
assocModel.attributes.each_with_index do |attribute, index|
|
91
|
+
if attribute.key == assocColumn
|
92
|
+
assocIndex = index
|
93
|
+
end
|
94
|
+
end
|
95
|
+
while array > 0
|
96
|
+
val = assocModel.find(id).attributes.values[assocIndex]
|
97
|
+
input += "\n\t\t\t<option value=\"" + id.to_s + "\">" + val.to_s + "</option>"
|
98
|
+
array --
|
99
|
+
end
|
100
|
+
input += "\n\t</select>"
|
101
|
+
@potential_keys_to_ignore.push(column)
|
102
|
+
@formMiddle.push(input)
|
103
|
+
return self
|
104
|
+
end
|
77
105
|
# Build starting code from class variables called upon by now!
|
78
106
|
def starter
|
79
107
|
if @formMethodHidden
|