Skip to content

Commit 7d8e1ae

Browse files
update webform example 1
2 parents 9504c50 + a8f4679 commit 7d8e1ae

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

app/controllers/webforms/weg001_create_instance_controller.rb

+10-6
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ def create_web_form_template
1212
access_token: session[:ds_access_token]
1313
}
1414

15-
web_form_template_id = Webforms::Eg001CreateInstanceService.new(args).create_web_form_template
16-
Utils::FileUtils.new.replace_template_id(File.join('data', Rails.application.config.web_form_config_file), web_form_template_id)
17-
session[:web_form_template_id] = web_form_template_id
18-
19-
redirect_to '/weg001webForm'
15+
begin
16+
web_form_template_id = Webforms::Eg001CreateInstanceService.new(args).create_web_form_template
17+
Utils::FileUtils.new.replace_template_id(File.join('data', Rails.application.config.web_form_config_file), web_form_template_id)
18+
session[:web_form_template_id] = web_form_template_id
19+
20+
redirect_to '/weg001webForm'
21+
rescue DocuSign_eSign::ApiError => e
22+
handle_error(e)
23+
end
2024
end
2125

2226
def create_web_form_instance
@@ -49,7 +53,7 @@ def get_web_form_create_view
4953

5054
additional_page = @example['AdditionalPage'].find { |p| p['Name'] == 'create_web_form' }
5155
@title = @example['ExampleName']
52-
@description = additional_page['ResultsPageText']
56+
@description = format_string(additional_page['ResultsPageText'], 'data')
5357

5458
render 'webforms/weg001_create_instance/web_form_create'
5559
end

app/services/webforms/eg001_create_instance_service.rb

+15-15
Original file line numberDiff line numberDiff line change
@@ -95,38 +95,38 @@ def make_web_forms_template
9595
# Create a sign_here tab (field on the document)
9696
sign_here = DocuSign_eSign::SignHere.new(
9797
'documentId' => '1', 'tabLabel' => 'Signature',
98-
'anchorString' => '/SignHere/', 'anchorUnits' => 'pixel',
99-
'anchorXOffset' => '20', 'anchorYOffset' => '10'
98+
'anchorString' => '/SignHere/', 'anchorUnits' => 'pixels',
99+
'anchorXOffset' => '0', 'anchorYOffset' => '0'
100100
)
101101
check = DocuSign_eSign::Checkbox.new(
102102
'documentId' => '1', 'tabLabel' => 'Yes',
103-
'anchorString' => '/SMS/', 'anchorUnits' => 'pixel',
104-
'anchorXOffset' => '20', 'anchorYOffset' => '10'
103+
'anchorString' => '/SMS/', 'anchorUnits' => 'pixels',
104+
'anchorXOffset' => '0', 'anchorYOffset' => '0'
105105
)
106106
text1 = DocuSign_eSign::Text.new(
107107
'documentId' => '1', 'tabLabel' => 'FullName',
108-
'anchorString' => '/FullName/', 'anchorUnits' => 'pixel',
109-
'anchorXOffset' => '20', 'anchorYOffset' => '10'
108+
'anchorString' => '/FullName/', 'anchorUnits' => 'pixels',
109+
'anchorXOffset' => '0', 'anchorYOffset' => '0'
110110
)
111111
text2 = DocuSign_eSign::Text.new(
112112
'documentId' => '1', 'tabLabel' => 'PhoneNumber',
113-
'anchorString' => '/PhoneNumber/', 'anchorUnits' => 'pixel',
114-
'anchorXOffset' => '20', 'anchorYOffset' => '10'
113+
'anchorString' => '/PhoneNumber/', 'anchorUnits' => 'pixels',
114+
'anchorXOffset' => '0', 'anchorYOffset' => '0'
115115
)
116116
text3 = DocuSign_eSign::Text.new(
117117
'documentId' => '1', 'tabLabel' => 'Company',
118-
'anchorString' => '/Company/', 'anchorUnits' => 'pixel',
119-
'anchorXOffset' => '20', 'anchorYOffset' => '10'
118+
'anchorString' => '/Company/', 'anchorUnits' => 'pixels',
119+
'anchorXOffset' => '0', 'anchorYOffset' => '0'
120120
)
121121
text4 = DocuSign_eSign::Text.new(
122122
'documentId' => '1', 'tabLabel' => 'JobTitle',
123-
'anchorString' => '/JobTitle/', 'anchorUnits' => 'pixel',
124-
'anchorXOffset' => '20', 'anchorYOffset' => '10'
123+
'anchorString' => '/JobTitle/', 'anchorUnits' => 'pixels',
124+
'anchorXOffset' => '0', 'anchorYOffset' => '0'
125125
)
126126
date_signed = DocuSign_eSign::DateSigned.new(
127127
'documentId' => '1', 'tabLabel' => 'DateSigned',
128-
'anchorString' => '/Date/', 'anchorUnits' => 'pixel',
129-
'anchorXOffset' => '20', 'anchorYOffset' => '10'
128+
'anchorString' => '/Date/', 'anchorUnits' => 'pixels',
129+
'anchorXOffset' => '0', 'anchorYOffset' => '0'
130130
)
131131

132132
# Add the tabs model to the signer
@@ -139,7 +139,7 @@ def make_web_forms_template
139139
)
140140
# Create top two objects
141141
envelope_template_definition = DocuSign_eSign::EnvelopeTemplate.new(
142-
'description' => 'Example template created via the API',
142+
'description' => 'Example template created via the eSignature API',
143143
'shared' => 'false'
144144
)
145145

data/web-form-config.json

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)