forme 0.8.0 → 0.9.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/CHANGELOG +18 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +5 -1
- data/Rakefile +8 -2
- data/lib/forme.rb +45 -8
- data/lib/forme/version.rb +1 -1
- data/lib/sequel/plugins/forme.rb +27 -9
- data/spec/forme_spec.rb +21 -3
- data/spec/sequel_plugin_spec.rb +20 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 037794e39f62d0052a5dd6a6832c41326d31b851
|
4
|
+
data.tar.gz: 1f3aa7418616002d1e2443ccea5313a874925851
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55d5ebeb5602c3eaed73448d2973bfc12b97a3ffb5d39c4caee227c83cbca0142252c96d8c99c90a178071a9ca3302b99f62316180d2a2f36d2358ac8afeb7d9
|
7
|
+
data.tar.gz: 9bb5afa6c4192585b71bad482d7de6c138efc11b4e00310c9376f147884c1e6f2e399475504329502ca0281374f89ee20b3874e54649cb6dd3953dc197fdad94
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
=== 0.9.0 (2013-12-13)
|
2
|
+
|
3
|
+
* Support :input_defaults Form option for setting defaults for inputs by type (jeremyevans)
|
4
|
+
|
5
|
+
* Make html_usa serializer convert date/datetime inputs to text for better compatibility (jeremyevans)
|
6
|
+
|
7
|
+
* Format BigDecimal in standard notation instead of default scientific notation (jeremyevans)
|
8
|
+
|
9
|
+
* Make trtd wrapper always have labels on left side (jeremyevans)
|
10
|
+
|
11
|
+
* Make trtd wrapper always use 2 cells (jeremyevans)
|
12
|
+
|
13
|
+
* Use regular (not-multiple) select box for *_to_many associations for :multiple=>false option (jeremyevans)
|
14
|
+
|
15
|
+
* Associtions in the Sequel plugin now support a :dataset option to specify dataset to use for options (jeremyevans)
|
16
|
+
|
17
|
+
* The :name_method option used for associations in the Sequel plugin now allows for arbitrary callables (jeremyevans)
|
18
|
+
|
1
19
|
=== 0.8.0 (2013-10-30)
|
2
20
|
|
3
21
|
* form calls without block or :inputs or :button options are now handled correctly in the Sinatra integration (jeremyevans)
|
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -9,7 +9,11 @@ Forme is a HTML forms library for ruby with the following goals:
|
|
9
9
|
|
10
10
|
= Demo Site
|
11
11
|
|
12
|
-
A demo site is available at http://forme.
|
12
|
+
A demo site is available at http://forme-demo.jeremyevans.net
|
13
|
+
|
14
|
+
= Documentation Site
|
15
|
+
|
16
|
+
RDoc Documentation is available at http://forme.jeremyevans.net
|
13
17
|
|
14
18
|
= Source Code
|
15
19
|
|
data/Rakefile
CHANGED
@@ -22,11 +22,17 @@ end
|
|
22
22
|
|
23
23
|
### RDoc
|
24
24
|
|
25
|
-
RDOC_DEFAULT_OPTS = ["--
|
25
|
+
RDOC_DEFAULT_OPTS = ["--line-numbers", "--inline-source", '--title', 'Forme']
|
26
|
+
|
27
|
+
begin
|
28
|
+
gem 'rdoc', '= 3.12.2'
|
29
|
+
gem 'hanna-nouveau'
|
30
|
+
RDOC_DEFAULT_OPTS.concat(['-f', 'hanna'])
|
31
|
+
rescue Gem::LoadError
|
32
|
+
end
|
26
33
|
|
27
34
|
rdoc_task_class = begin
|
28
35
|
require "rdoc/task"
|
29
|
-
RDOC_DEFAULT_OPTS.concat(['-f', 'hanna'])
|
30
36
|
RDoc::Task
|
31
37
|
rescue LoadError
|
32
38
|
require "rake/rdoctask"
|
data/lib/forme.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'date'
|
2
|
+
require 'bigdecimal'
|
2
3
|
require 'forme/version'
|
3
4
|
|
4
5
|
# Forme is designed to make creating HTML forms easier. Flexibility and
|
@@ -146,6 +147,7 @@ module Forme
|
|
146
147
|
# :error_handler :: Sets the +error_handler+ for the form
|
147
148
|
# :formatter :: Sets the +formatter+ for the form
|
148
149
|
# :hidden_tags :: Sets the hidden tags to automatically add to this form.
|
150
|
+
# :input_defaults :: Sets the default options for each input type
|
149
151
|
# :inputs_wrapper :: Sets the +inputs_wrapper+ for the form
|
150
152
|
# :labeler :: Sets the +labeler+ for the form
|
151
153
|
# :wrapper :: Sets the +wrapper+ for the form
|
@@ -168,6 +170,10 @@ module Forme
|
|
168
170
|
# respond to +call+ or be a registered symbol.
|
169
171
|
attr_reader :wrapper
|
170
172
|
|
173
|
+
# Set the default options for inputs by type. This should be a hash with
|
174
|
+
# input type string keys and values that are hashes of input options.
|
175
|
+
attr_reader :input_defaults
|
176
|
+
|
171
177
|
# The +inputs_wrapper+ determines how calls to +inputs+ are wrapped. Must
|
172
178
|
# respond to +call+ or be a registered symbol.
|
173
179
|
attr_reader :inputs_wrapper
|
@@ -242,6 +248,7 @@ module Forme
|
|
242
248
|
end
|
243
249
|
config = CONFIGURATIONS[@opts[:config]||Forme.default_config]
|
244
250
|
TRANSFORMER_TYPES.each{|k| instance_variable_set(:"@#{k}", transformer(k, @opts.fetch(k, config[k])))}
|
251
|
+
@input_defaults = @opts[:input_defaults] || {}
|
245
252
|
@hidden_tags = @opts[:hidden_tags]
|
246
253
|
@nesting = []
|
247
254
|
end
|
@@ -525,7 +532,8 @@ module Forme
|
|
525
532
|
|
526
533
|
# Set the +form+, +type+, and +opts+.
|
527
534
|
def initialize(form, type, opts={})
|
528
|
-
@form, @type
|
535
|
+
@form, @type = form, type
|
536
|
+
@opts = (form.input_defaults[type.to_s] || {}).merge(opts)
|
529
537
|
end
|
530
538
|
|
531
539
|
# Replace the +opts+ by merging the given +hash+ into +opts+,
|
@@ -1051,7 +1059,17 @@ module Forme
|
|
1051
1059
|
end
|
1052
1060
|
Forme.register_transformer(:wrapper, :trtd) do |tag, input|
|
1053
1061
|
a = Array(tag).flatten
|
1054
|
-
|
1062
|
+
labels, other = a.partition{|e| e.is_a?(Tag) && e.type.to_s == 'label'}
|
1063
|
+
if labels.length == 1
|
1064
|
+
ltd = labels
|
1065
|
+
rtd = other
|
1066
|
+
elsif a.length == 1
|
1067
|
+
ltd = [a.first]
|
1068
|
+
rtd = a[1..-1]
|
1069
|
+
else
|
1070
|
+
ltd = a
|
1071
|
+
end
|
1072
|
+
input.tag(:tr, input.opts[:wrapper_attr], [input.tag(:td, {}, ltd), input.tag(:td, {}, rtd)])
|
1055
1073
|
end
|
1056
1074
|
|
1057
1075
|
# Default inputs_wrapper used by the library, uses a fieldset.
|
@@ -1150,7 +1168,7 @@ module Forme
|
|
1150
1168
|
case tag
|
1151
1169
|
when Tag
|
1152
1170
|
if SELF_CLOSING.include?(tag.type)
|
1153
|
-
"<#{tag.type}#{attr_html(tag)}/>"
|
1171
|
+
"<#{tag.type}#{attr_html(tag.attr)}/>"
|
1154
1172
|
else
|
1155
1173
|
"#{serialize_open(tag)}#{call(tag.children)}#{serialize_close(tag)}"
|
1156
1174
|
end
|
@@ -1162,6 +1180,8 @@ module Forme
|
|
1162
1180
|
format_time(tag)
|
1163
1181
|
when Date
|
1164
1182
|
format_date(tag)
|
1183
|
+
when BigDecimal
|
1184
|
+
tag.to_s('F')
|
1165
1185
|
when Raw
|
1166
1186
|
tag.to_s
|
1167
1187
|
else
|
@@ -1171,7 +1191,7 @@ module Forme
|
|
1171
1191
|
|
1172
1192
|
# Returns the opening part of the given tag.
|
1173
1193
|
def serialize_open(tag)
|
1174
|
-
"<#{tag.type}#{attr_html(tag)}>"
|
1194
|
+
"<#{tag.type}#{attr_html(tag.attr)}>"
|
1175
1195
|
end
|
1176
1196
|
|
1177
1197
|
# Returns the closing part of the given tag.
|
@@ -1208,16 +1228,33 @@ module Forme
|
|
1208
1228
|
|
1209
1229
|
# Transforms the +tag+'s attributes into an html string, sorting by the keys
|
1210
1230
|
# and quoting and html escaping the values.
|
1211
|
-
def attr_html(
|
1212
|
-
attr =
|
1231
|
+
def attr_html(attr)
|
1232
|
+
attr = attr.to_a.reject{|k,v| v.nil?}
|
1213
1233
|
" #{attr.map{|k, v| "#{k}=\"#{attr_value(v)}\""}.sort.join(' ')}" unless attr.empty?
|
1214
1234
|
end
|
1215
1235
|
end
|
1216
1236
|
|
1217
1237
|
# Overrides formatting of dates and times to use an American format without
|
1218
1238
|
# timezones.
|
1219
|
-
|
1220
|
-
Forme.register_transformer(:serializer, :html_usa,
|
1239
|
+
class Serializer::AmericanTime < Serializer
|
1240
|
+
Forme.register_transformer(:serializer, :html_usa, new)
|
1241
|
+
|
1242
|
+
def call(tag)
|
1243
|
+
case tag
|
1244
|
+
when Tag
|
1245
|
+
if tag.type.to_s == 'input' && %w'date datetime'.include?((tag.attr[:type] || tag.attr['type']).to_s)
|
1246
|
+
attr = tag.attr.dup
|
1247
|
+
attr.delete(:type)
|
1248
|
+
attr.delete('type')
|
1249
|
+
attr['type'] = 'text'
|
1250
|
+
"<#{tag.type}#{attr_html(attr)}/>"
|
1251
|
+
else
|
1252
|
+
super
|
1253
|
+
end
|
1254
|
+
else
|
1255
|
+
super
|
1256
|
+
end
|
1257
|
+
end
|
1221
1258
|
|
1222
1259
|
private
|
1223
1260
|
|
data/lib/forme/version.rb
CHANGED
data/lib/sequel/plugins/forme.rb
CHANGED
@@ -145,7 +145,7 @@ module Sequel # :nodoc:
|
|
145
145
|
# If the field is a column, use the column's type to determine
|
146
146
|
# an appropriate field type. If the field is an association,
|
147
147
|
# use either a regular or multiple select input (or multiple radios or
|
148
|
-
# checkboxes if the related :
|
148
|
+
# checkboxes if the related :as option is used). If it's not a
|
149
149
|
# column or association, but the object responds to +field+,
|
150
150
|
# create a text input. Otherwise, raise an +Error+.
|
151
151
|
def input
|
@@ -290,8 +290,8 @@ module Sequel # :nodoc:
|
|
290
290
|
|
291
291
|
# Create a select input made up of options for all entries the object
|
292
292
|
# could be associated to, with the one currently associated to being selected.
|
293
|
-
# If the :
|
294
|
-
# a select box. For :
|
293
|
+
# If the :as=>:radio option is used, use multiple radio buttons instead of
|
294
|
+
# a select box. For :as=>:radio, you can also provide a :tag_wrapper option
|
295
295
|
# used to wrap the individual radio buttons.
|
296
296
|
def association_many_to_one(ref)
|
297
297
|
key = ref[:key]
|
@@ -319,8 +319,8 @@ module Sequel # :nodoc:
|
|
319
319
|
|
320
320
|
# Create a multiple select input made up of options for all entries the object
|
321
321
|
# could be associated to, with all of the ones currently associated to being selected.
|
322
|
-
# If the :
|
323
|
-
# a multiple select box. For :
|
322
|
+
# If the :as=>:checkbox option is used, use multiple checkboxes instead of
|
323
|
+
# a multiple select box. For :as=>:checkbox, you can also provide a :tag_wrapper option
|
324
324
|
# used to wrap the individual checkboxes.
|
325
325
|
def association_one_to_many(ref)
|
326
326
|
key = ref[:key]
|
@@ -340,7 +340,7 @@ module Sequel # :nodoc:
|
|
340
340
|
wrapper ? wrapper.call(cbs, _input(:checkbox, opts)) : cbs
|
341
341
|
else
|
342
342
|
opts[:id] = form.namespaced_id(field) unless opts.has_key?(:id)
|
343
|
-
opts[:multiple] = true
|
343
|
+
opts[:multiple] = true unless opts.has_key?(:multiple)
|
344
344
|
_input(:select, opts)
|
345
345
|
end
|
346
346
|
end
|
@@ -349,8 +349,25 @@ module Sequel # :nodoc:
|
|
349
349
|
# Return an array of two element arrays representing the
|
350
350
|
# select options that should be created.
|
351
351
|
def association_select_options(ref)
|
352
|
-
|
353
|
-
|
352
|
+
case ds = opts[:dataset]
|
353
|
+
when nil
|
354
|
+
ds = association_select_options_dataset(ref)
|
355
|
+
when Proc, Method
|
356
|
+
ds = ds.call(association_select_options_dataset(ref))
|
357
|
+
end
|
358
|
+
rows = ds.all
|
359
|
+
|
360
|
+
case name_method = forme_name_method(ref)
|
361
|
+
when Symbol, String
|
362
|
+
rows.map{|a| [a.send(name_method), a.pk]}
|
363
|
+
else
|
364
|
+
rows.map{|a| [name_method.call(a), a.pk]}
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
# The dataset to use to retrieve the association select options
|
369
|
+
def association_select_options_dataset(ref)
|
370
|
+
obj.send(:_apply_association_options, ref, ref.associated_dataset).unlimited
|
354
371
|
end
|
355
372
|
|
356
373
|
# Delegate to the +form+.
|
@@ -359,7 +376,8 @@ module Sequel # :nodoc:
|
|
359
376
|
end
|
360
377
|
|
361
378
|
# If the column allows +NULL+ values, use a three-valued select
|
362
|
-
# input. If not, use a simple checkbox.
|
379
|
+
# input. If not, use a simple checkbox. You can also use :as=>:select,
|
380
|
+
# as :as=>:radio, or :as=>:checkbox to specify a particular style.
|
363
381
|
def input_boolean(sch)
|
364
382
|
unless opts.has_key?(:as)
|
365
383
|
opts[:as] = sch[:allow_null] ? :select : :checkbox
|
data/spec/forme_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')
|
2
|
-
require 'date'
|
3
2
|
|
4
3
|
describe "Forme plain forms" do
|
5
4
|
def sel(opts, s)
|
@@ -306,6 +305,10 @@ describe "Forme plain forms" do
|
|
306
305
|
@f.tag(:div, :foo=>Time.utc(2011, 6, 5, 4, 3, 2)).to_s.should =~ /<div foo="2011-06-05 04:03:02(GMT|UTC)"><\/div>/
|
307
306
|
end
|
308
307
|
|
308
|
+
specify "should format bigdecimals in standard notation" do
|
309
|
+
@f.tag(:div, :foo=>BigDecimal.new('10000.010')).to_s.should == '<div foo="10000.01"></div>'
|
310
|
+
end
|
311
|
+
|
309
312
|
specify "inputs should accept a :wrapper option to use a custom wrapper" do
|
310
313
|
@f.input(:text, :wrapper=>:li).to_s.should == '<li><input type="text"/></li>'
|
311
314
|
end
|
@@ -367,6 +370,12 @@ describe "Forme plain forms" do
|
|
367
370
|
@f.inputs(:inputs_wrapper=>:ol){@f.input(:textarea)}.to_s.should == '<ol><textarea></textarea></ol>'
|
368
371
|
end
|
369
372
|
|
373
|
+
specify "should support setting defaults for inputs at the form level" do
|
374
|
+
f = Forme::Form.new(:input_defaults=>{'text'=>{:size=>20}, 'textarea'=>{:cols=>80, :rows=>6}})
|
375
|
+
f.input(:text, :name=>"foo").to_s.should == '<input name="foo" size="20" type="text"/>'
|
376
|
+
f.input(:textarea, :name=>"foo").to_s.should == '<textarea cols="80" name="foo" rows="6"></textarea>'
|
377
|
+
end
|
378
|
+
|
370
379
|
specify "invalid custom transformers should raise an Error" do
|
371
380
|
proc{Forme::Form.new(:wrapper=>Object.new)}.should raise_error(Forme::Error)
|
372
381
|
proc{@f.input(:textarea, :wrapper=>Object.new).to_s}.should raise_error(Forme::Error)
|
@@ -475,7 +484,7 @@ describe "Forme built-in custom" do
|
|
475
484
|
end
|
476
485
|
|
477
486
|
specify "wrapper: trtd wraps tag in an tr/td" do
|
478
|
-
Forme::Form.new(:wrapper=>:trtd).input(:textarea, :id=>'foo').to_s.should == '<tr><td><textarea id="foo"></textarea></td></tr>'
|
487
|
+
Forme::Form.new(:wrapper=>:trtd).input(:textarea, :id=>'foo').to_s.should == '<tr><td><textarea id="foo"></textarea></td><td></td></tr>'
|
479
488
|
end
|
480
489
|
|
481
490
|
specify "wrapper: trtd supports multiple tags in separate tds" do
|
@@ -486,6 +495,10 @@ describe "Forme built-in custom" do
|
|
486
495
|
Forme::Form.new(:wrapper=>:trtd, :labeler=>:explicit).input(:textarea, :id=>'foo', :label=>'Foo', :error=>'Bar').to_s.should == '<tr><td><label for="foo">Foo</label></td><td><textarea class="error" id="foo"></textarea><span class="error_message">Bar</span></td></tr>'
|
487
496
|
end
|
488
497
|
|
498
|
+
specify "wrapper: trtd should handle inputs with label after" do
|
499
|
+
Forme::Form.new(:wrapper=>:trtd, :labeler=>:explicit).input(:checkbox, :id=>'foo', :name=>'foo', :label=>'Foo').to_s.should == '<tr><td><label for="foo">Foo</label></td><td><input id="foo_hidden" name="foo" type="hidden" value="0"/><input id="foo" name="foo" type="checkbox"/></td></tr>'
|
500
|
+
end
|
501
|
+
|
489
502
|
specify "inputs_wrapper: ol wraps tags in an ol" do
|
490
503
|
Forme::Form.new(:inputs_wrapper=>:ol, :wrapper=>:li).inputs([:textarea]).to_s.should == '<ol><li><textarea></textarea></li></ol>'
|
491
504
|
end
|
@@ -503,7 +516,7 @@ describe "Forme built-in custom" do
|
|
503
516
|
end
|
504
517
|
|
505
518
|
specify "inputs_wrapper: table wraps tags in an table" do
|
506
|
-
Forme::Form.new(:inputs_wrapper=>:table, :wrapper=>:trtd).inputs([:textarea]).to_s.should == '<table><tr><td><textarea></textarea></td></tr></table>'
|
519
|
+
Forme::Form.new(:inputs_wrapper=>:table, :wrapper=>:trtd).inputs([:textarea]).to_s.should == '<table><tr><td><textarea></textarea></td><td></td></tr></table>'
|
507
520
|
end
|
508
521
|
|
509
522
|
specify "serializer: html_usa formats dates and datetimes in American format without timezones" do
|
@@ -512,6 +525,11 @@ describe "Forme built-in custom" do
|
|
512
525
|
Forme::Form.new(:serializer=>:html_usa).tag(:div, :foo=>Time.utc(2011, 6, 5, 4, 3, 2)).to_s.should == '<div foo="06/05/2011 04:03:02AM"></div>'
|
513
526
|
end
|
514
527
|
|
528
|
+
specify "serializer: html_usa should convert date and datetime inputs into text inputs" do
|
529
|
+
Forme::Form.new(:serializer=>:html_usa).input(:date, :value=>Date.new(2011, 6, 5)).to_s.should == '<input type="text" value="06/05/2011"/>'
|
530
|
+
Forme::Form.new(:serializer=>:html_usa).input(:datetime, :value=>DateTime.new(2011, 6, 5, 16, 3, 2)).to_s.should == '<input type="text" value="06/05/2011 04:03:02PM"/>'
|
531
|
+
end
|
532
|
+
|
515
533
|
specify "serializer: text uses plain text output instead of html" do
|
516
534
|
Forme::Form.new(:serializer=>:text).input(:textarea, :label=>"Foo", :value=>"Bar").to_s.should == "Foo: Bar\n\n"
|
517
535
|
Forme::Form.new(:serializer=>:text).input(:text, :label=>"Foo", :value=>"Bar").to_s.should == "Foo: Bar\n\n"
|
data/spec/sequel_plugin_spec.rb
CHANGED
@@ -171,6 +171,21 @@ describe "Forme Sequel::Model forms" do
|
|
171
171
|
@c.input(:artist, :name_method=>:idname).to_s.should == '<label>Artist: <select id="album_artist_id" name="album[artist_id]"><option value=""></option><option value="1">1a</option><option selected="selected" value="2">2d</option></select></label>'
|
172
172
|
end
|
173
173
|
|
174
|
+
specify "should support :name_method option being a callable object" do
|
175
|
+
@b.input(:artist, :name_method=>lambda{|obj| obj.idname * 2}).to_s.should == '<label>Artist: <select id="album_artist_id" name="album[artist_id]"><option value=""></option><option selected="selected" value="1">1a1a</option><option value="2">2d2d</option></select></label>'
|
176
|
+
@c.input(:artist, :name_method=>lambda{|obj| obj.idname * 2}).to_s.should == '<label>Artist: <select id="album_artist_id" name="album[artist_id]"><option value=""></option><option value="1">1a1a</option><option selected="selected" value="2">2d2d</option></select></label>'
|
177
|
+
end
|
178
|
+
|
179
|
+
specify "should support :dataset option providing dataset to search" do
|
180
|
+
@b.input(:artist, :dataset=>Artist.reverse_order(:name)).to_s.should == '<label>Artist: <select id="album_artist_id" name="album[artist_id]"><option value=""></option><option value="2">d</option><option selected="selected" value="1">a</option></select></label>'
|
181
|
+
@c.input(:artist, :dataset=>Artist.reverse_order(:name)).to_s.should == '<label>Artist: <select id="album_artist_id" name="album[artist_id]"><option value=""></option><option selected="selected" value="2">d</option><option value="1">a</option></select></label>'
|
182
|
+
end
|
183
|
+
|
184
|
+
specify "should support :dataset option being a callback proc returning modified dataset to search" do
|
185
|
+
@b.input(:artist, :dataset=>proc{|ds| ds.reverse_order(:name)}).to_s.should == '<label>Artist: <select id="album_artist_id" name="album[artist_id]"><option value=""></option><option value="2">d</option><option selected="selected" value="1">a</option></select></label>'
|
186
|
+
@c.input(:artist, :dataset=>proc{|ds| ds.reverse_order(:name)}).to_s.should == '<label>Artist: <select id="album_artist_id" name="album[artist_id]"><option value=""></option><option selected="selected" value="2">d</option><option value="1">a</option></select></label>'
|
187
|
+
end
|
188
|
+
|
174
189
|
specify "should try a list of methods to get a suitable one for select box naming" do
|
175
190
|
al = Class.new(Album){def self.name() 'Album' end}
|
176
191
|
ar = Class.new(Artist)
|
@@ -209,6 +224,11 @@ describe "Forme Sequel::Model forms" do
|
|
209
224
|
@c.input(:tags).to_s.should == '<label>Tags: <select id="album_tag_pks" multiple="multiple" name="album[tag_pks][]"><option value="1">s</option><option selected="selected" value="2">t</option><option value="3">u</option></select></label>'
|
210
225
|
end
|
211
226
|
|
227
|
+
specify "should use a regular select box for *_to_many associations if multiple if false" do
|
228
|
+
@b.input(:tracks, :multiple=>false).to_s.should == '<label>Tracks: <select id="album_track_pks" name="album[track_pks][]"><option value="1">m</option><option value="2">n</option><option value="3">o</option></select></label>'
|
229
|
+
@c.input(:tags, :multiple=>false).to_s.should == '<label>Tags: <select id="album_tag_pks" name="album[tag_pks][]"><option value="1">s</option><option value="2">t</option><option value="3">u</option></select></label>'
|
230
|
+
end
|
231
|
+
|
212
232
|
specify "should use multiple checkboxes for one_to_many associations if :as=>:checkbox" do
|
213
233
|
@b.input(:tracks, :as=>:checkbox).to_s.should == '<span class="label">Tracks</span><label class="option"><input checked="checked" id="album_track_pks_1" name="album[track_pks][]" type="checkbox" value="1"/> m</label><label class="option"><input checked="checked" id="album_track_pks_2" name="album[track_pks][]" type="checkbox" value="2"/> n</label><label class="option"><input id="album_track_pks_3" name="album[track_pks][]" type="checkbox" value="3"/> o</label>'
|
214
234
|
@c.input(:tracks, :as=>:checkbox).to_s.should == '<span class="label">Tracks</span><label class="option"><input id="album_track_pks_1" name="album[track_pks][]" type="checkbox" value="1"/> m</label><label class="option"><input id="album_track_pks_2" name="album[track_pks][]" type="checkbox" value="2"/> n</label><label class="option"><input checked="checked" id="album_track_pks_3" name="album[track_pks][]" type="checkbox" value="3"/> o</label>'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Forme is a forms library with the following goals:
|
@@ -30,15 +30,15 @@ files:
|
|
30
30
|
- README.rdoc
|
31
31
|
- Rakefile
|
32
32
|
- spec/forme_spec.rb
|
33
|
-
- spec/
|
33
|
+
- spec/rails_integration_spec.rb
|
34
|
+
- spec/sequel_helper.rb
|
34
35
|
- spec/sequel_plugin_spec.rb
|
35
36
|
- spec/sinatra_integration_spec.rb
|
36
|
-
- spec/
|
37
|
-
- spec/rails_integration_spec.rb
|
37
|
+
- spec/spec_helper.rb
|
38
38
|
- lib/forme.rb
|
39
|
-
- lib/forme/version.rb
|
40
|
-
- lib/forme/sinatra.rb
|
41
39
|
- lib/forme/rails.rb
|
40
|
+
- lib/forme/sinatra.rb
|
41
|
+
- lib/forme/version.rb
|
42
42
|
- lib/sequel/plugins/forme.rb
|
43
43
|
homepage: http://gihub.com/jeremyevans/forme
|
44
44
|
licenses: []
|