定制 sandritsch91/yii2-widget-jsignature 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sandritsch91/yii2-widget-jsignature

最新稳定版本:1.1.2

Composer 安装命令:

composer require sandritsch91/yii2-widget-jsignature

包简介

A jSignature widget for Yii2

README 文档

README

A jSignature widget for yii2

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist sandritsch91/yii2-widget-jsignature

or add

"sandritsch91/yii2-widget-jsignature": "*"

to the require section of your composer.json

Good to know

Loading a signature is only supported for the following formats:

  • native
  • base30

If you need to load a signature again, use one of these formats.

Usage

Widget

with a model:

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
    'clientOptions' => [],                      // Optional. The options for the jSignature plugin
    '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
]);

with an ActiveForm:

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
]);

without a model:

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
]);

Widget options

  • format: The format of the signature. Defaults to svgbase64
    • default
    • native
    • base30
    • svg
    • svgbase64
    • image
  • htmlClass: The class used to generate the form field. Defaults to yii\helpers\Html::class
  • clientEvents: The client events to be attached to the textarea. Defaults to []
    • change: Triggered after each stroke
  • wrapperOptions: The options for the wrapper div. Defaults to []

Helper

User the sandritsch91\yii2\jSignature\JSignatureHelper to convert the signature to a different format.

Possible conversions are:

  • base30 to native
  • native to svg
  • base30 to svg
  • native to image
  • base30 to image

统计信息

  • 总下载量: 127
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-18