Forked from micschk/silverstripe-signaturefield which no longer appears to be maintained.
A silverstripe signature form field based on https://github.com/szimek/signature_pad
composer require davejtoews/silverstripe-signaturefield
A signaturefield will be scaffolded if field is set to 'Signature' (field holds base64 png image of signature)
use DaveJToews\SignatureField\Signature;
class Contract extends DataObject {
private static $db = array(
'Signature' => Signature::class,
);
}
Or explicitly add a SignatureField to a form (eg for non-scafolded formfields or front-end)
use DaveJToews\SignatureField\SignatureField;
...
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main',
SignatureField::create('Signature')
);
return $fields;
}
If using this field on a front end form, outside of the CMS, jQuery is required. By default this module will load a packaged version of jQuery. This may conflict with existing versions if you have separately installed jQuery on your front end. To remove the included version of jQuery and make use of your own version, add the following to your yaml config
DaveJToews\SignatureField\SignatureField:
include_jquery: false
Scaling issues may occur on high DPI screens: szimek/signature_pad#679
The js is bundled using parcel.js. To make javascript changes
- run
yarn install
to install dependencies. - make requisite changes in
javascript/src/signature_pad.init.js
- run
yarn build
to compile changes