formula 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/formula.rb +19 -13
- data/lib/formula/version.rb +1 -1
- metadata +2 -2
data/lib/formula.rb
CHANGED
@@ -106,7 +106,7 @@ module Formula
|
|
106
106
|
# <%= f.label(:name, "Name:") %>
|
107
107
|
# ...
|
108
108
|
# <div class="hint">Please use your full name.</div>
|
109
|
-
# <div class="error"
|
109
|
+
# <div class="error">...</div>
|
110
110
|
# </div>
|
111
111
|
|
112
112
|
def block(method, options = {}, &block)
|
@@ -119,7 +119,7 @@ module Formula
|
|
119
119
|
components << @template.capture(&block)
|
120
120
|
|
121
121
|
options[:container] ||= {}
|
122
|
-
options[:container][:class] = arrayorize(options[:container][:class]) << ::Formula.block_class
|
122
|
+
options[:container][:class] = arrayorize(options[:container][:class]) << ::Formula.block_class << method
|
123
123
|
|
124
124
|
components << @template.content_tag(::Formula.hint_tag , options[:hint ], :class => ::Formula.hint_class ) if options[:hint ]
|
125
125
|
components << @template.content_tag(::Formula.error_tag, options[:error], :class => ::Formula.error_class) if options[:error]
|
@@ -152,17 +152,19 @@ module Formula
|
|
152
152
|
# <div class="block">
|
153
153
|
# <%= f.label(:name)
|
154
154
|
# <div class="input string"><%= f.text_field(:name)</div>
|
155
|
+
# <div class="error">...</div>
|
155
156
|
# </div>
|
156
157
|
# <div class="block">
|
157
158
|
# <%= f.label(:email)
|
158
159
|
# <div class="input string"><%= f.email_field(:email)</div>
|
159
|
-
#
|
160
|
+
# <div class="error">...</div>
|
160
161
|
# </div>
|
161
162
|
# <div class="block half">
|
162
163
|
# <div class="input">
|
163
164
|
# <%= f.label(:password_a, "Password")
|
164
165
|
# <%= f.password_field(:password_a)
|
165
166
|
# <div class="hint">It's a secret!</div>
|
167
|
+
# <div class="error">...</div>
|
166
168
|
# </div>
|
167
169
|
# </div>
|
168
170
|
# <div class="block half">
|
@@ -170,6 +172,7 @@ module Formula
|
|
170
172
|
# <%= f.label(:password_b, "Password")
|
171
173
|
# <%= f.password_field(:password_b)
|
172
174
|
# <div class="hint">It's a secret!</div>
|
175
|
+
# <div class="error">...</div>
|
173
176
|
# </div>
|
174
177
|
# </div>
|
175
178
|
|
@@ -209,35 +212,38 @@ module Formula
|
|
209
212
|
#
|
210
213
|
# Usage:
|
211
214
|
#
|
212
|
-
# f.association(:
|
213
|
-
# f.association(:
|
214
|
-
# f.association(:
|
215
|
+
# f.association(:category, Category.all, :id, :name, :hint => "What do you do?")
|
216
|
+
# f.association(:category, Category.all, :id, :name, :association => { :prompt => "Category?" })
|
217
|
+
# f.association(:category, Category.all, :id, :name, :association => { :html => { :class => "category" } })
|
215
218
|
#
|
216
219
|
# Equivalent:
|
217
220
|
#
|
218
221
|
# <div>
|
219
222
|
# <div class="association">
|
220
|
-
# <%= f.label(:
|
223
|
+
# <%= f.label(:category)
|
221
224
|
# <div class="association">
|
222
|
-
# <%= f.collection_select(:
|
225
|
+
# <%= f.collection_select(:category, Category.all, :id, :name) %>
|
223
226
|
# </div>
|
224
227
|
# <div class="hint">What do you do?</div>
|
228
|
+
# <div class="error">...</div>
|
225
229
|
# </div>
|
226
230
|
# </div>
|
227
231
|
# <div>
|
228
232
|
# <div class="association">
|
229
|
-
# <%= f.label(:
|
233
|
+
# <%= f.label(:category)
|
230
234
|
# <div class="association">
|
231
|
-
# <%= f.collection_select(:
|
235
|
+
# <%= f.collection_select(:category, Category.all, :id, :name, { :prompt => "Category") } %>
|
232
236
|
# </div>
|
237
|
+
# <div class="error">...</div>
|
233
238
|
# </div>
|
234
239
|
# </div>
|
235
240
|
# <div>
|
236
241
|
# <div class="association">
|
237
|
-
# <%= f.label(:
|
242
|
+
# <%= f.label(:category)
|
238
243
|
# <div class="association">
|
239
|
-
# <%= f.collection_select(:
|
244
|
+
# <%= f.collection_select(:category, Category.all, :id, :name, {}, { :class => "category" } %>
|
240
245
|
# </div>
|
246
|
+
# <div class="error">...</div>
|
241
247
|
# </div>
|
242
248
|
# </div>
|
243
249
|
|
@@ -250,7 +256,7 @@ module Formula
|
|
250
256
|
self.block(method, options) do
|
251
257
|
@template.content_tag(::Formula.association_tag, :class => [::Formula.association_class, options[:as]]) do
|
252
258
|
case options[:as]
|
253
|
-
when :select then collection_select(method, collection, value, text,
|
259
|
+
when :select then collection_select(:"#{method}_id", collection, value, text,
|
254
260
|
options[:association], options[:association].delete(:html))
|
255
261
|
end
|
256
262
|
end
|
data/lib/formula/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: formula
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kevin Sylvestre
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-02-
|
13
|
+
date: 2011-02-23 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|