PHP code example of sandritsch91 / yii2-widget-jsignature

1. Go to this page and download the library: Download sandritsch91/yii2-widget-jsignature library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sandritsch91 / yii2-widget-jsignature example snippets


use sandritsch91\yii2\jSignature\JSignature;

echo JSignature::widget([
    'model' => $model,                          // The model to be used in the form
    'attribute' => 'signature',                 // The attribute to be used in the form
    'format' => 'svgbase64',                    // The format of the signature. Defaults to svgbase64
    'htmlClass' => yii\helpers\Html::class,     // Optional. The class used to generate the form field
    'clientEvents' => [                         // Optional. Pass the client events to be attached to the textarea
        'change' => 'function() { console.log("changed"); }'
    ],
    'wrapperOptions' => [...]                   // Optional. The options for the wrapper div
]);

use sandritsch91\yii2\jSignature\JSignature;

echo $form->field($model, 'content')->widget(JSignature::class, [
    'format' => 'svgbase64',                    // The format of the signature. Defaults to svgbase64
    'htmlClass' => yii\helpers\Html::class,     // Optional. The class used to generate the form field
    'clientEvents' => [                         // Optional. Pass the client events to be attached to the textarea
        'change' => 'function() { console.log("changed"); }'
    ],
    'wrapperOptions' => [...]                   // Optional. The options for the wrapper div
]);

use sandritsch91\yii2\jSignature\JSignature;

echo JSignature::widget([
    'name' => 'myText',                         // The name of the input
    'value' => ...,                             // The value of the input, depends on the format
    'format' => 'svgbase64',                    // The format of the signature. Defaults to svgbase64
    'htmlClass' => yii\helpers\Html::class,     // Optional. The class used to generate the form field
    'clientEvents' => [                         // Optional. Pass the client events to be attached to the textarea
        'change' => 'function() { console.log("changed"); }'
    ],
    'wrapperOptions' => [...]                   // Optional. The options for the wrapper div
]);