Search code examples
phptabsdocusignapiform-datadocusigncompositetmplts

How to pre-fill the input field and pass the same through composite template while creating envelope


I have been trying to pre-populate the data into form fields created by admin during template creation by making call to server template and adding tabs with the values

I have found this links: Passing template tabs value while creating envelope Retrieving information from a signed document DocuSign API

But it is not helping much as i'm trying the php code as shown below:

     $signer1 = new \DocuSign\eSign\Model\Signer([
        'email' => $signer_email, 'name' => $signer_name,
        'role_name' => "signer", 'recipient_id' => "1",
        'client_user_id' => $clientUserId,
        'defaultrecipient'=> "true",
        'tabs' => new \DocuSign\eSign\Model\Tabs( [
            'textTabs' => new \DocuSign\eSign\Model\Text ([
                'tabLabel' => "dob",
                'value'=> "12/3/1998"
            ])
        ])
    ]);

    $recipients_server_template = new \DocuSign\eSign\Model\Recipients([
        'signers' => [$signer1]]);

    $comp_template1 = new \DocuSign\eSign\Model\CompositeTemplate([
        'composite_template_id' => "1",
        'server_templates' => [
            new \DocuSign\eSign\Model\ServerTemplate([
                'sequence' => "1", 'template_id' => '6ef9c9c2-2f15-4a80-9643-f3c5a310dcdc'])
        ],
        'inline_templates' => [
            new \DocuSign\eSign\Model\InlineTemplate([
                'sequence' => "1",
                'recipients' => $recipients_server_template])
        ],
    ]);

    $envelopeDefinition = new \DocuSign\eSign\Model\EnvelopeDefinition([
        'email_subject' => "Please sign this document",
        //'documents' => [$comp_template1], # The order in the docs array determines the order in the envelope

        'composite_templates' => [$comp_template1],
        /*'recipients' => new DocuSign\eSign\Model\Recipients(['signers' => [$signer]]), */
        'status' => "sent" 
    ]);

As u can see above, "dob" is my custom field created in server template and is pulled from there and using above code i just want to assign it a value. But it is not getting populated when I visit the document demo site.

Am I doing anything wrong??

Any help much appreciated, Thanks


Solution

  • I've been working on something similar to this today myself and found the following solution seemed to work.

    $textTabArray = array(array('tabLabel' => "regnum", 'value' => "testy"));
    $taber = array("textTabs" => $textTabArray);
    
    //for me tabs were in a different method
    'tabs' => $taber
    

    I used a slightly different method using a PHP OAuth and signing found here:

    https://github.com/docusign/eg-03-php-auth-code-grant/blob/master/src/EG009UseTemplate.php

    Adding tabs to the signer and template role model.

    Hope that helps!