Function:
$form->addInput('hidden', $input_name, $value, $label, 'class=signature-pad, data-background-color=#336699, data-pen-color=#fff, data-width=100%, data-clear-button=true, data-clear-button-class=btn btn-sm btn-warning, data-clear-button-text=clear, data-fv-not-empty___message=You must sign to accept the license agreement, required');
To activate the Signature pad plugin, add the signature-pad class to the input element.
there is no need to call the "addPlugin" function.
Arguments:
- $input_name [String]
- the input field name
- $value [String]
- the input field value
- $label [String]
- the input field label
Special notes:
The signature value is sent with the hidden input. The value is a base64 png image (data:image/png;base64
).
Here's how to save the image on the server:
$data_uri = $_POST['fieldname'];
$encoded_image = explode(',', $data_uri)[1];
$decoded_image = base64_decode($encoded_image);
file_put_contents('signature.png', $decoded_image);
Options:
Pass options with data attributes. Example:
$form->addInput('hidden', 'user-signature', '', 'Sign to confirm your agreement', 'class=signature-pad, data-background-color=#336699, data-pen-color=#fff, data-width=100%, data-clear-button=true, data-clear-button-class=btn btn-sm btn-warning, data-clear-button-text=clear, required');
Available options:
- data-width [Number] | [percent]
- the input field width. Accepts only number (in pixels) or percent value.
- data-background-color [String]
- the background color in valid CSS format
- data-pen-color [String]
- the pen color in valid CSS format
- data-clear-button [Boolean]
- show a button to clear the signature
- data-clear-button-class [String]
- the CSS classes for the clear button
- data-clear-button-text [String]
- the text of the clear button