fluffery 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -5,13 +5,15 @@ module Fluffery
|
|
5
5
|
|
6
6
|
include Fluffery::Forms::Utilities
|
7
7
|
|
8
|
-
# Access the template object
|
9
|
-
|
8
|
+
# Access the template object, and create an accessor which will track the order
|
9
|
+
# in which our fields are used in the form. This way we have the ability to capture that state for re-use in emails etc.
|
10
|
+
attr_accessor :template, :field_order
|
10
11
|
|
11
12
|
# Sets up options custom to our form builder.
|
12
13
|
# It also overrides the default error proc so we can use something more custom.
|
13
14
|
#
|
14
15
|
def initialize(object_name, object, template, options, proc)
|
16
|
+
@field_order ||= []
|
15
17
|
without_error_proc do
|
16
18
|
super(object_name, object, template, options, proc)
|
17
19
|
end
|
@@ -42,9 +42,13 @@ module Fluffery
|
|
42
42
|
# 1. If a field has errors, wrap it with the defined error template.
|
43
43
|
# 2. Also add our error class to the field itself.
|
44
44
|
#
|
45
|
-
def render_with_fluff(method, options, html_options = nil, &block)
|
45
|
+
def render_with_fluff(method, options, html_options = nil, &block)
|
46
|
+
|
47
|
+
@field_order << method
|
48
|
+
|
46
49
|
_options = html_options.nil? ? options : html_options
|
47
50
|
_options = validator.add_html_attributes(method, _options)
|
51
|
+
|
48
52
|
# If no errors, simply return.
|
49
53
|
unless validator.errors_for?(method)
|
50
54
|
return block.call
|
@@ -11,7 +11,7 @@ module Fluffery
|
|
11
11
|
|
12
12
|
class Pattern < Fluffery::Forms::Validation::Base
|
13
13
|
def self.create(attribute, options, matcher)
|
14
|
-
options.reverse_merge!('pattern' => matcher.
|
14
|
+
options.reverse_merge!('pattern' => matcher.source) unless matcher.nil?
|
15
15
|
options
|
16
16
|
end
|
17
17
|
end
|
data/lib/fluffery/version.rb
CHANGED