问题
I am using the DocuSign PHP SDK and I would like to fill in values for existing text tabs / fields on my template.
I've tried using the following:
$textTab = new \DocuSign\eSign\Model\Text();
$textTab->setTabId('f432a532-327e-4335-39ff-fk3285d732pd');
$textTab->setValue('3333 Kingman Ave');
$tabs = new DocuSign\eSign\Model\Tabs();
$tabs->setTextTabs(array($textTab));
$templateRole->setTabs($tabs);
where the parameter passed to setTabId()
is taken from the tabId property of an object from the textTabs array in the template JSON export.
I've also tried using
$textTab->setTabLabel('corresponding-label-id')
in place of
$textTab->setTabId()
Neither changes the value in the tab they refer to. What's the correct syntax to set a custom value for an existing text tab using the PHP SDK?
回答1:
See example EG017SetTemplateTabValues.php
You set the values via the role object for the signer/recipient.
Eg
# create the envelope definition with the template_id
$envelope_definition = new \DocuSign\eSign\Model\EnvelopeDefinition([
'status' => 'sent', 'template_id' => $args['template_id']
]);
# Set the values for the fields in the template
$check1 = new \DocuSign\eSign\Model\Checkbox([
'tab_label' => 'ckAuthorization', 'selected' => "true"]);
$number1 = new \DocuSign\eSign\Model\Number([
'tab_label' => "numbersOnly", 'value' => '54321']);
$radio_group = new \DocuSign\eSign\Model\RadioGroup(['group_name' => "radio1",
# You only need to provide the radio entry for the entry you're selecting
'radios' => [
new \DocuSign\eSign\Model\Radio(['value' => "white", 'selected' => "true"]),
]]);
$text = new \DocuSign\eSign\Model\Text([
'tab_label' => "text", 'value' => "Jabberwocky!"]);
# Pull together the existing tabs in a Tabs object:
$tabs = new \DocuSign\eSign\Model\Tabs([
'checkbox_tabs' => [$check1, $check3], 'number_tabs' => [$number1],
'radio_group_tabs' => [$radio_group], 'text_tabs' => [$text]]);
# Create the template role elements to connect the signer and cc recipients
# to the template
$signer = new \DocuSign\eSign\Model\TemplateRole([
'email' => $args['signer_email'], 'name' => $args['signer_name'],
'role_name' => 'signer',
'tabs' => $tabs # Set tab values
]);
# Create a cc template role.
$cc = new \DocuSign\eSign\Model\TemplateRole([
'email' => $args['cc_email'], 'name' => $args['cc_name'],
'role_name' => 'cc'
]);
# Add the TemplateRole objects to the envelope object
$envelope_definition->setTemplateRoles([$signer, $cc]);
return $envelope_definition;
来源:https://stackoverflow.com/questions/53776599/docusign-php-sdk-how-do-i-populate-existing-text-tabs-programmatically