lib/populate_me/mongo/crushyform.rb in populate-me-0.0.9 vs lib/populate_me/mongo/crushyform.rb in populate-me-0.0.10
- old
+ new
@@ -30,9 +30,16 @@
"#{tag}#{js}"
end,
:slug => proc do |m,c,o|
crushyform_types[:string].call(m,c,o)
end,
+ :price => proc do |m,c,o|
+ crushid = m.field_id_for(c)
+ price_main, price_cents = o[:input_value].to_i.divmod(100)
+ out = "<input type='text' name='%s[]' id='%s-main' class='%s price-main' value='%s' size='10' /> • "
+ out << "<input type='text' name='%s[]' id='%s-cents' class='%s price-cents' value='%s' size='2' maxlength='2' style='width: auto;' />"
+ out % [o[:input_name], crushid, o[:input_class], price_main, o[:input_name], crushid, o[:input_class], price_cents]
+ end,
:boolean => proc do |m,c,o|
crushid = m.field_id_for(c)
checked = 'checked' if o[:input_value]
out = "<input type='hidden' name='%s' value='false' id='%s-off' />\n"
out += "<input type='checkbox' name='%s' value='true' id='%s' class='%s' %s />\n"