BrianTheCoder-ratpack 0.2.2 → 0.2.3

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.
Files changed (3) hide show
  1. data/VERSION.yml +1 -1
  2. data/lib/ratpack/forms.rb +5 -5
  3. metadata +1 -1
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 2
3
- :patch: 2
3
+ :patch: 3
4
4
  :major: 0
data/lib/ratpack/forms.rb CHANGED
@@ -2,10 +2,10 @@ module RatPack
2
2
  module Forms
3
3
  def error_messages_for(obj = nil, opts = {})
4
4
  return unless obj.respond_to?(:errors)
5
+ return if obj.errors.blank?
5
6
  html = tag(:h2, "Form submission failed be cause of #{obj.errors.size} #{pluralize("error",obj.errors.size)}")
6
- obj.errors.each do |field,msg|
7
- html << tag(:li,msg)
8
- end
7
+ msgs = obj.errors.map{|error| error.map{|msg| tag(:li,msg)}}.flatten
8
+ tag(:div, html + tag(:ul,msgs), :class => "error")
9
9
  end
10
10
 
11
11
  %w(text password hidden file).each do |kind|
@@ -62,12 +62,12 @@ module RatPack
62
62
  private
63
63
 
64
64
  def form_field(type, content, attrs)
65
- attrs[:id] = attrs[:name] unless attrs.has_key?(:id)
65
+ attrs[:id] = attrs[:name].gsub(/(\[)(.+?)\]$/,'_\2') unless attrs.has_key?(:id)
66
66
  build_field(attrs) + tag(type, content, attrs)
67
67
  end
68
68
 
69
69
  def closed_form_field(type, attrs)
70
- attrs[:id] = attrs[:name] unless attrs.has_key?(:id)
70
+ attrs[:id] = attrs[:name].gsub(/(\[)(.+?)\]$/,'_\2') unless attrs.has_key?(:id)
71
71
  build_field(attrs) + self_closing_tag(type, attrs)
72
72
  end
73
73
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BrianTheCoder-ratpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - brianthecoder