radiant-forms-extension 2.0.1 → 3.1.1
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.
- data/README.md +85 -14
- data/VERSION +1 -1
- data/app/controllers/forms_controller.rb +34 -17
- data/app/models/form.rb +7 -1
- data/app/models/form_mail.rb +118 -0
- data/app/models/form_mailer.rb +16 -0
- data/app/models/response.rb +6 -1
- data/config/routes.rb +1 -1
- data/db/migrate/20100929150423_change_to_updated_by_id.rb +15 -0
- data/forms_extension.rb +12 -8
- data/lib/forms/config.rb +30 -0
- data/lib/forms/controllers/application_controller.rb +39 -0
- data/lib/forms/controllers/site_controller.rb +13 -0
- data/lib/forms/interface/forms.rb +25 -0
- data/lib/forms/models/extension.rb +25 -0
- data/lib/forms/models/page.rb +14 -0
- data/lib/forms/tags/core.rb +201 -0
- data/lib/forms/tags/helpers.rb +54 -0
- data/lib/forms/tags/responses.rb +58 -0
- data/radiant-forms-extension.gemspec +16 -12
- data/spec/controllers/forms_controller_spec.rb +13 -13
- data/spec/datasets/forms.rb +4 -4
- data/spec/lib/forms/tags_spec.rb +3 -14
- data/spec/models/response_spec.rb +2 -2
- metadata +29 -13
- data/lib/forms/addon_methods.rb +0 -14
- data/lib/forms/admin_ui.rb +0 -23
- data/lib/forms/application_controller_extensions.rb +0 -20
- data/lib/forms/page_extensions.rb +0 -6
- data/lib/forms/site_controller_extensions.rb +0 -19
- data/lib/forms/tags.rb +0 -277
- data/spec/lib/forms/addon_methods_spec.rb +0 -41
@@ -0,0 +1,201 @@
|
|
1
|
+
class TagError < StandardError; end
|
2
|
+
|
3
|
+
module Forms
|
4
|
+
module Tags
|
5
|
+
module Core
|
6
|
+
include Radiant::Taggable
|
7
|
+
|
8
|
+
desc %{
|
9
|
+
Render a form and its contents
|
10
|
+
<pre><code><r:form name="object[key]" [method, url] /></code></pre>
|
11
|
+
|
12
|
+
* *name* the name of the form
|
13
|
+
* *method* url submission method [ post, get, delete, put ]
|
14
|
+
* *url* address to submit the form to
|
15
|
+
}
|
16
|
+
tag 'form' do |tag|
|
17
|
+
if tag.attr['name'].present?
|
18
|
+
if tag.locals.form = Form.find_by_title(tag.attr['name'])
|
19
|
+
tag.attr['id'] ||= 'form_' + tag.locals.form.title
|
20
|
+
tag.attr['method'] ||= 'put'
|
21
|
+
tag.attr['action'] ||= tag.locals.form.action.blank? ? "/forms/#{tag.locals.form.id}" : tag.locals.form.action
|
22
|
+
|
23
|
+
parse(Forms::Tags::Helpers.render(tag))
|
24
|
+
else
|
25
|
+
raise TagError, "Could not find '#{tag.attr['name']}' form"
|
26
|
+
end
|
27
|
+
else
|
28
|
+
tag.expand
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc %{
|
33
|
+
Render a @<label />@ tag to be used inside a form
|
34
|
+
<pre><code><r:form:label for="object[key]" /></code></pre>
|
35
|
+
|
36
|
+
**Required**
|
37
|
+
* *for* the name of the field you are relating the tag to
|
38
|
+
|
39
|
+
_A label is a piece of text which activates its related input when clicked_
|
40
|
+
}
|
41
|
+
tag 'form:label' do |tag|
|
42
|
+
Forms::Tags::Helpers.require!(tag,'form:label','for')
|
43
|
+
|
44
|
+
tag.attr['for'] = tag.attr['for'].gsub('[','_').gsub(']','') unless tag.attr['for'].nil?
|
45
|
+
|
46
|
+
%(<label #{Forms::Tags::Helpers.attributes(tag)}>#{tag.expand}</label>)
|
47
|
+
end
|
48
|
+
|
49
|
+
%w(text password reset checkbox radio hidden file button).each do |type|
|
50
|
+
desc %{
|
51
|
+
Render a @<#{type}>...</#{type}>@ tag to be used in a form
|
52
|
+
<pre><code><r:form:#{type} name="object[key]" /></code></pre>
|
53
|
+
|
54
|
+
**Required**
|
55
|
+
* *name* the name of the data to be sent
|
56
|
+
|
57
|
+
**Optional**
|
58
|
+
* *class* css class names
|
59
|
+
* *placeholder* default text, which is cleared when clicked
|
60
|
+
* *maxlength* the maximum amount of characters
|
61
|
+
}
|
62
|
+
tag "form:#{type}" do |tag|
|
63
|
+
Forms::Tags::Helpers.require!(tag,"form:#{type}",'name')
|
64
|
+
|
65
|
+
value = tag.attr['value']
|
66
|
+
tag.attr['type'] = type
|
67
|
+
|
68
|
+
%(<input type="#{type}" value="#{value}" #{Forms::Tags::Helpers.attributes(tag)} />)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
desc %{
|
73
|
+
Renders a @<select>...</select>@ tag to be used in a form
|
74
|
+
|
75
|
+
<pre><code><r:form:select name="object[key]"><r:option value="text" /></r:form:select></code></pre>
|
76
|
+
|
77
|
+
**Required**
|
78
|
+
* *name* the name of the data to be sent
|
79
|
+
|
80
|
+
**Optional**
|
81
|
+
* *class* css class names
|
82
|
+
|
83
|
+
_@<r:option />@ tags may be nested inside the tag to automatically generate options_
|
84
|
+
}
|
85
|
+
tag 'form:select' do |tag|
|
86
|
+
Forms::Tags::Helpers.require!(tag,'form:select','name')
|
87
|
+
|
88
|
+
tag.locals.parent_tag_name = tag.attr['name']
|
89
|
+
tag.locals.parent_tag_type = 'select'
|
90
|
+
|
91
|
+
%(<select #{Forms::Tags::Helpers.attributes(tag)}>#{tag.expand}</select>)
|
92
|
+
end
|
93
|
+
|
94
|
+
desc %{
|
95
|
+
Renders a series of @<input type="radio"/>@ tags to be used in a form
|
96
|
+
|
97
|
+
<pre><code><r:form:radios name="object[value]" value="text"><r:option value="text" /></r:form:radios></code></pre>
|
98
|
+
|
99
|
+
**Required**
|
100
|
+
* *name* the name of the data to be sent
|
101
|
+
|
102
|
+
**Optional**
|
103
|
+
* *class* css class names
|
104
|
+
|
105
|
+
_@<r:option />@ tags may be nested inside the tag to automatically generate options_
|
106
|
+
}
|
107
|
+
tag 'form:radios' do |tag|
|
108
|
+
Forms::Tags::Helpers.require!(tag,'form:radios','name')
|
109
|
+
|
110
|
+
tag.locals.parent_tag_name = tag.attr['name']
|
111
|
+
tag.locals.parent_tag_type = 'radios'
|
112
|
+
tag.expand
|
113
|
+
end
|
114
|
+
|
115
|
+
desc %{
|
116
|
+
Renders an @<option/>@ tag if the parent is a
|
117
|
+
@<r:form:select>...</r:form:select>@ or @<r:form:radios>...</r:form:radios>@
|
118
|
+
|
119
|
+
**Required**
|
120
|
+
* *value* the value you want to be sent if selected
|
121
|
+
}
|
122
|
+
tag 'form:option' do |tag|
|
123
|
+
value = tag.attr['value'] || tag.expand
|
124
|
+
|
125
|
+
if tag.locals.parent_tag_type == 'select'
|
126
|
+
text = tag.expand.length == 0 ? value : tag.expand
|
127
|
+
|
128
|
+
extra = { 'value' => value}
|
129
|
+
%(<option #{Forms::Tags::Helpers.attributes(tag, extra)}>#{text}</option>)
|
130
|
+
elsif tag.locals.parent_tag_type == 'radios'
|
131
|
+
name= tag.locals.parent_tag_type == 'radios' ? tag.locals.parent_tag_name : tag.attr['name']
|
132
|
+
id = name.gsub('[','_').gsub(']','') + '_' + value
|
133
|
+
|
134
|
+
extra = { 'id' => id, 'value' => value, 'name' => name, 'type' => 'radio' }
|
135
|
+
%(<input #{Forms::Tags::Helpers.attributes(tag, extra)} />)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
desc %{
|
140
|
+
Renders an @<input type="submit" />@ tag for a form.
|
141
|
+
|
142
|
+
**Optional**
|
143
|
+
* *value* the text on the submit
|
144
|
+
}
|
145
|
+
tag 'form:submit' do |tag|
|
146
|
+
value = tag.attr['value'] || 'submit'
|
147
|
+
extra = { 'value' => value, 'type' => 'submit', 'class' => 'submit', 'name' => 'submit' }
|
148
|
+
%(<input #{Forms::Tags::Helpers.attributes(tag, extra)} />)
|
149
|
+
end
|
150
|
+
|
151
|
+
desc %{
|
152
|
+
Query the data from a submitted form
|
153
|
+
|
154
|
+
@<r:form:read name="object[value]" />@ access the object which was submitted
|
155
|
+
|
156
|
+
_This can only be used in the content section of a form, use @<r:form:get />@ in pages_
|
157
|
+
}
|
158
|
+
tag 'form:read' do |tag|
|
159
|
+
Forms::Tags::Helpers.require!(tag,'form:read','name')
|
160
|
+
data = Forms::Tags::Responses.retrieve(tag.locals.page.data, tag.attr['name'])
|
161
|
+
end
|
162
|
+
|
163
|
+
desc %{
|
164
|
+
Clears the response object
|
165
|
+
|
166
|
+
@<r:response:clear />@
|
167
|
+
}
|
168
|
+
tag 'response:clear' do |tag|
|
169
|
+
Forms::Tags::Responses.clear(tag)
|
170
|
+
|
171
|
+
nil
|
172
|
+
end
|
173
|
+
|
174
|
+
desc %{
|
175
|
+
Allows access to the response of a submitted form
|
176
|
+
@<r:response>...<r:get /><r:clear />...</r:response>@
|
177
|
+
|
178
|
+
_Will not expand if a form has not been submitted or has been cleared_
|
179
|
+
}
|
180
|
+
tag 'response' do |tag|
|
181
|
+
tag.locals.response = Forms::Tags::Responses.current(tag,request)
|
182
|
+
|
183
|
+
tag.expand if tag.locals.response.present? and tag.locals.response.result.present?
|
184
|
+
end
|
185
|
+
|
186
|
+
desc %{
|
187
|
+
Access the attributes of a submitted form.
|
188
|
+
|
189
|
+
@<r:response:get name="object[value]" />@ an object which was submitted with the form
|
190
|
+
@<r:response:get name="result[mail][value]" />@ a response to the mail extension hooking the form
|
191
|
+
|
192
|
+
_Refer to the readme on extensions to find out what they return_
|
193
|
+
}
|
194
|
+
tag 'response:get' do |tag|
|
195
|
+
Forms::Tags::Helpers.require!(tag,'response:get','name')
|
196
|
+
|
197
|
+
result = Forms::Tags::Responses.retrieve(tag.locals.response.result, tag.attr['name']).to_s
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Forms
|
2
|
+
module Tags
|
3
|
+
module Helpers
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def render(tag)
|
8
|
+
string = %{<form enctype="multipart/form-data" method="post" #{attributes(tag)}>\n}
|
9
|
+
string << %{<input type="hidden" name="_method" value="#{tag.attr['method']}" />\n}
|
10
|
+
string << %{<input type="hidden" name="page_id" value="#{tag.locals.page.id}" />\n}
|
11
|
+
string << %{<r:form>}
|
12
|
+
string << tag.locals.form.body
|
13
|
+
string << %{</r:form>}
|
14
|
+
string << %{</form>}
|
15
|
+
end
|
16
|
+
|
17
|
+
def attributes(tag, extras={})
|
18
|
+
id = tag.attr['name'] || extras['name']
|
19
|
+
id = id || tag.attr['for'] + '_label' if tag.attr['for']
|
20
|
+
id = id.gsub('[','_').gsub(']','') unless id.nil?
|
21
|
+
|
22
|
+
attrs = {
|
23
|
+
'id' => id,
|
24
|
+
'class' => tag.attr['type'],
|
25
|
+
'name' => nil,
|
26
|
+
'for' => nil,
|
27
|
+
'action' => nil,
|
28
|
+
'placeholder' => nil,
|
29
|
+
'value' => nil,
|
30
|
+
'maxlength' => nil
|
31
|
+
}.merge(extras)
|
32
|
+
|
33
|
+
result = attrs.collect do |k,v|
|
34
|
+
v = (tag.attr[k] || v)
|
35
|
+
next if v.blank?
|
36
|
+
%(#{k}="#{v}")
|
37
|
+
end.reject{|e| e.blank?}
|
38
|
+
|
39
|
+
result.join(' ')
|
40
|
+
end
|
41
|
+
|
42
|
+
def require!(tag,name,key)
|
43
|
+
if tag.attr[key].present?
|
44
|
+
return true
|
45
|
+
else
|
46
|
+
raise "'<r:#{name} />' requires the '#{key}' attribute"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Forms
|
2
|
+
module Tags
|
3
|
+
module Responses
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def current(tag, request)
|
8
|
+
response = nil
|
9
|
+
|
10
|
+
if tag.locals.response.present?
|
11
|
+
response = tag.locals.response
|
12
|
+
elsif tag.locals.page.request.present?
|
13
|
+
session = tag.locals.page.request.session[:form_response]
|
14
|
+
begin
|
15
|
+
response = Response.find(session)
|
16
|
+
rescue
|
17
|
+
if session == Object
|
18
|
+
response = Response.create
|
19
|
+
tag.locals.page.request.session[:form_response] = result.id
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
response
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns the value from a hash when in input key is sent
|
28
|
+
# @source = hash
|
29
|
+
# @key
|
30
|
+
def retrieve(source, key)
|
31
|
+
result = nil
|
32
|
+
|
33
|
+
if source.present?
|
34
|
+
data = key.gsub("[","|").gsub("]","").split("|")
|
35
|
+
|
36
|
+
if data.present?
|
37
|
+
result = source.fetch(data[0].to_sym)
|
38
|
+
data.delete_at(0)
|
39
|
+
|
40
|
+
if data.length and result.present?
|
41
|
+
data.each do |i|
|
42
|
+
result = result.fetch(i.to_sym) rescue nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
result
|
49
|
+
end
|
50
|
+
|
51
|
+
def clear(tag)
|
52
|
+
tag.locals.response.update_attribute('result', nil)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{radiant-forms-extension}
|
8
|
-
s.version = "
|
8
|
+
s.version = "3.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["dirkkelly"]
|
12
|
-
s.date = %q{2010-08
|
12
|
+
s.date = %q{2010-10-08}
|
13
13
|
s.description = %q{Send data from a page to a form handler, extendable with addons}
|
14
14
|
s.email = %q{dirk.kelly@squaretalent.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -23,6 +23,8 @@ Gem::Specification.new do |s|
|
|
23
23
|
"app/controllers/admin/forms_controller.rb",
|
24
24
|
"app/controllers/forms_controller.rb",
|
25
25
|
"app/models/form.rb",
|
26
|
+
"app/models/form_mail.rb",
|
27
|
+
"app/models/form_mailer.rb",
|
26
28
|
"app/models/form_page.rb",
|
27
29
|
"app/models/response.rb",
|
28
30
|
"app/views/admin/forms/_fields.html.haml",
|
@@ -40,19 +42,22 @@ Gem::Specification.new do |s|
|
|
40
42
|
"db/migrate/002_create_user_observer.rb",
|
41
43
|
"db/migrate/003_rename_output_to_content.rb",
|
42
44
|
"db/migrate/004_create_responses.rb",
|
45
|
+
"db/migrate/20100929150423_change_to_updated_by_id.rb",
|
43
46
|
"forms_extension.rb",
|
44
|
-
"lib/forms/
|
45
|
-
"lib/forms/
|
46
|
-
"lib/forms/
|
47
|
-
"lib/forms/
|
48
|
-
"lib/forms/
|
49
|
-
"lib/forms/
|
47
|
+
"lib/forms/config.rb",
|
48
|
+
"lib/forms/controllers/application_controller.rb",
|
49
|
+
"lib/forms/controllers/site_controller.rb",
|
50
|
+
"lib/forms/interface/forms.rb",
|
51
|
+
"lib/forms/models/extension.rb",
|
52
|
+
"lib/forms/models/page.rb",
|
53
|
+
"lib/forms/tags/core.rb",
|
54
|
+
"lib/forms/tags/helpers.rb",
|
55
|
+
"lib/forms/tags/responses.rb",
|
50
56
|
"lib/tasks/forms_extension_tasks.rake",
|
51
57
|
"public/images/admin/extensions/form/form.png",
|
52
58
|
"radiant-forms-extension.gemspec",
|
53
59
|
"spec/controllers/forms_controller_spec.rb",
|
54
60
|
"spec/datasets/forms.rb",
|
55
|
-
"spec/lib/forms/addon_methods_spec.rb",
|
56
61
|
"spec/lib/forms/tags_spec.rb",
|
57
62
|
"spec/models/form_spec.rb",
|
58
63
|
"spec/models/response_spec.rb",
|
@@ -62,12 +67,11 @@ Gem::Specification.new do |s|
|
|
62
67
|
s.homepage = %q{http://github.com/squaretalent/radiant-forms-extension}
|
63
68
|
s.rdoc_options = ["--charset=UTF-8"]
|
64
69
|
s.require_paths = ["lib"]
|
65
|
-
s.rubygems_version = %q{1.3.
|
70
|
+
s.rubygems_version = %q{1.3.7}
|
66
71
|
s.summary = %q{Forms Extension for Radiant CMS}
|
67
72
|
s.test_files = [
|
68
73
|
"spec/controllers/forms_controller_spec.rb",
|
69
74
|
"spec/datasets/forms.rb",
|
70
|
-
"spec/lib/forms/addon_methods_spec.rb",
|
71
75
|
"spec/lib/forms/tags_spec.rb",
|
72
76
|
"spec/models/form_spec.rb",
|
73
77
|
"spec/models/response_spec.rb",
|
@@ -78,7 +82,7 @@ Gem::Specification.new do |s|
|
|
78
82
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
79
83
|
s.specification_version = 3
|
80
84
|
|
81
|
-
if Gem::Version.new(Gem::
|
85
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
82
86
|
else
|
83
87
|
end
|
84
88
|
else
|
@@ -9,8 +9,8 @@ describe FormsController do
|
|
9
9
|
@page = pages(:home)
|
10
10
|
@form = forms(:test)
|
11
11
|
@params = {
|
12
|
-
'
|
13
|
-
'
|
12
|
+
'id' => @form.id,
|
13
|
+
'data' => 'test'
|
14
14
|
}
|
15
15
|
mock(Page).find(anything) { @page }
|
16
16
|
mock(Form).find(anything) { @form }
|
@@ -19,7 +19,7 @@ describe FormsController do
|
|
19
19
|
context 'initialize' do
|
20
20
|
|
21
21
|
before :each do
|
22
|
-
|
22
|
+
put :update, @params
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should assign the page' do
|
@@ -31,7 +31,7 @@ describe FormsController do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'should put the params into the page data' do
|
34
|
-
assigns(:page).data[
|
34
|
+
assigns(:page).data[:request].should == @params['request']
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'should find/create a response object' do
|
@@ -39,7 +39,7 @@ describe FormsController do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should add the params to the response result' do
|
42
|
-
assigns(:response).result[
|
42
|
+
assigns(:response).result[:request].should == @params['request']
|
43
43
|
end
|
44
44
|
|
45
45
|
end
|
@@ -47,13 +47,13 @@ describe FormsController do
|
|
47
47
|
context 'configuration' do
|
48
48
|
|
49
49
|
before :each do
|
50
|
-
|
50
|
+
put :update, @params
|
51
51
|
end
|
52
52
|
|
53
53
|
context 'configuration exists' do
|
54
54
|
|
55
55
|
it 'should assign the configuration settings' do
|
56
|
-
assigns(:form)[:
|
56
|
+
assigns(:form)[:extensions][:test][:config].should == 'test'
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
@@ -75,17 +75,17 @@ describe FormsController do
|
|
75
75
|
context 'extensions' do
|
76
76
|
|
77
77
|
before :each do
|
78
|
-
|
78
|
+
put :update, @params
|
79
79
|
end
|
80
80
|
|
81
81
|
context 'extension configured' do
|
82
82
|
|
83
83
|
it 'should call that test extension' do
|
84
|
-
assigns(:response).result[
|
84
|
+
assigns(:response).result[:results][:test].should == { :response => 'test' }
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'should not call the alt extension' do
|
88
|
-
assigns(:response).result[
|
88
|
+
assigns(:response).result[:results][:alt].should be_nil
|
89
89
|
end
|
90
90
|
|
91
91
|
end
|
@@ -104,7 +104,7 @@ describe FormsController do
|
|
104
104
|
|
105
105
|
before :each do
|
106
106
|
@form.redirect_to = '/redirect/url'
|
107
|
-
|
107
|
+
put :update, @params
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'should redirect to the form redirect url' do
|
@@ -117,7 +117,7 @@ describe FormsController do
|
|
117
117
|
|
118
118
|
before :each do
|
119
119
|
@page.slug = '/page/url'
|
120
|
-
|
120
|
+
put :update, @params
|
121
121
|
end
|
122
122
|
|
123
123
|
it 'should render page url' do
|
@@ -132,7 +132,7 @@ describe FormsController do
|
|
132
132
|
|
133
133
|
before :each do
|
134
134
|
stub(@response).save { false }
|
135
|
-
|
135
|
+
put :update, @params
|
136
136
|
end
|
137
137
|
|
138
138
|
it 'should raise a form not submitted exception' do
|
data/spec/datasets/forms.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
class
|
2
|
-
|
1
|
+
class FormTest
|
2
|
+
include Forms::Models::Extension
|
3
3
|
def create
|
4
4
|
result = { :response => 'test' }
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
|
-
class
|
9
|
-
include Forms::
|
8
|
+
class FormAlt
|
9
|
+
include Forms::Models::Extension
|
10
10
|
def create
|
11
11
|
result = { :response => 'alt' }
|
12
12
|
end
|
data/spec/lib/forms/tags_spec.rb
CHANGED
@@ -14,12 +14,11 @@ describe Forms::Tags do
|
|
14
14
|
it 'should render the correct HTML' do
|
15
15
|
tag = %{<r:form name="#{@form.title}" />}
|
16
16
|
|
17
|
-
expected = %{<form enctype="multipart/form-data" name="#{@form.title}"
|
17
|
+
expected = %{<form enctype="multipart/form-data" method="post" name="#{@form.title}" action="/forms/#{@form.id}" id="form_test_form">
|
18
|
+
<input type="hidden" name="_method" value="put" />
|
18
19
|
<input type="hidden" name="page_id" value="#{@page.id}" />
|
19
|
-
<input type="hidden" name="form_id" value="#{@form.id}" />
|
20
20
|
<input type="text" value="" name="request[test]" class="text" id="request_test" /></form>}
|
21
|
-
|
22
|
-
@page.should render(tag).as(expected)
|
21
|
+
@page.should render(tag).as(expected)
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
@@ -109,14 +108,4 @@ describe Forms::Tags do
|
|
109
108
|
|
110
109
|
end
|
111
110
|
|
112
|
-
context 'form hooking' do
|
113
|
-
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
context 'form response' do
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
111
|
end
|
@@ -4,13 +4,13 @@ describe Response do
|
|
4
4
|
|
5
5
|
before :each do
|
6
6
|
@response = Response.new
|
7
|
-
@object = {
|
7
|
+
@object = { :test => 'test' }
|
8
8
|
end
|
9
9
|
|
10
10
|
context 'setting' do
|
11
11
|
|
12
12
|
it 'should store an object' do
|
13
|
-
@response.result.should
|
13
|
+
@response.result.should == {}
|
14
14
|
@response.result = @object
|
15
15
|
@response.result.should_not be_nil
|
16
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-forms-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 1
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 3
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 3.1.1
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- dirkkelly
|
@@ -9,7 +15,7 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-08
|
18
|
+
date: 2010-10-08 00:00:00 +08:00
|
13
19
|
default_executable:
|
14
20
|
dependencies: []
|
15
21
|
|
@@ -29,6 +35,8 @@ files:
|
|
29
35
|
- app/controllers/admin/forms_controller.rb
|
30
36
|
- app/controllers/forms_controller.rb
|
31
37
|
- app/models/form.rb
|
38
|
+
- app/models/form_mail.rb
|
39
|
+
- app/models/form_mailer.rb
|
32
40
|
- app/models/form_page.rb
|
33
41
|
- app/models/response.rb
|
34
42
|
- app/views/admin/forms/_fields.html.haml
|
@@ -46,19 +54,22 @@ files:
|
|
46
54
|
- db/migrate/002_create_user_observer.rb
|
47
55
|
- db/migrate/003_rename_output_to_content.rb
|
48
56
|
- db/migrate/004_create_responses.rb
|
57
|
+
- db/migrate/20100929150423_change_to_updated_by_id.rb
|
49
58
|
- forms_extension.rb
|
50
|
-
- lib/forms/
|
51
|
-
- lib/forms/
|
52
|
-
- lib/forms/
|
53
|
-
- lib/forms/
|
54
|
-
- lib/forms/
|
55
|
-
- lib/forms/
|
59
|
+
- lib/forms/config.rb
|
60
|
+
- lib/forms/controllers/application_controller.rb
|
61
|
+
- lib/forms/controllers/site_controller.rb
|
62
|
+
- lib/forms/interface/forms.rb
|
63
|
+
- lib/forms/models/extension.rb
|
64
|
+
- lib/forms/models/page.rb
|
65
|
+
- lib/forms/tags/core.rb
|
66
|
+
- lib/forms/tags/helpers.rb
|
67
|
+
- lib/forms/tags/responses.rb
|
56
68
|
- lib/tasks/forms_extension_tasks.rake
|
57
69
|
- public/images/admin/extensions/form/form.png
|
58
70
|
- radiant-forms-extension.gemspec
|
59
71
|
- spec/controllers/forms_controller_spec.rb
|
60
72
|
- spec/datasets/forms.rb
|
61
|
-
- spec/lib/forms/addon_methods_spec.rb
|
62
73
|
- spec/lib/forms/tags_spec.rb
|
63
74
|
- spec/models/form_spec.rb
|
64
75
|
- spec/models/response_spec.rb
|
@@ -74,28 +85,33 @@ rdoc_options:
|
|
74
85
|
require_paths:
|
75
86
|
- lib
|
76
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
77
89
|
requirements:
|
78
90
|
- - ">="
|
79
91
|
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
80
95
|
version: "0"
|
81
|
-
version:
|
82
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
83
98
|
requirements:
|
84
99
|
- - ">="
|
85
100
|
- !ruby/object:Gem::Version
|
101
|
+
hash: 3
|
102
|
+
segments:
|
103
|
+
- 0
|
86
104
|
version: "0"
|
87
|
-
version:
|
88
105
|
requirements: []
|
89
106
|
|
90
107
|
rubyforge_project:
|
91
|
-
rubygems_version: 1.3.
|
108
|
+
rubygems_version: 1.3.7
|
92
109
|
signing_key:
|
93
110
|
specification_version: 3
|
94
111
|
summary: Forms Extension for Radiant CMS
|
95
112
|
test_files:
|
96
113
|
- spec/controllers/forms_controller_spec.rb
|
97
114
|
- spec/datasets/forms.rb
|
98
|
-
- spec/lib/forms/addon_methods_spec.rb
|
99
115
|
- spec/lib/forms/tags_spec.rb
|
100
116
|
- spec/models/form_spec.rb
|
101
117
|
- spec/models/response_spec.rb
|
data/lib/forms/addon_methods.rb
DELETED