Hello,
Please note that the addFormElement method adds legacy form contents. These legacy contents have limited styles. In this case, the grey background is not a color applied to the checkbox but a MS Word setting.
If you run the following code:
$checkboxOptions = array('fontSize' => 12, 'defaultValue' => true);
$docx->addFormElement('checkbox', $checkboxOptions);
$docx->docxSettings(array('doNotShadeFormData' => true));
You set the doNotShadeFormData as true using docxSettings, so the checkbox background won't be grey.
Instead of addFormElement, we recommend you use addStructuredDocumentTag. For example:
$docx->addStructuredDocumentTag('checkbox', ['sz' => 18, 'fontSize' => 18, 'checked' => true]);
$docx->addStructuredDocumentTag('checkbox', ['sz' => 18, 'fontSize' => 18, 'checked' => true, 'highlightColor' => 'red']);
Regarding the character used for the checkbox, sorry but there's no option to change it to a custom one using the current stable release of phpdocx.
We have opened a task to the dev team to include this feature in this next stable release of phpdocx (there's no release date), and they have generated a patch in the testing branch, so a custom font and char using addStructuredDocumentTag can be set. For example, to use wingdings and tickmark:
$docx->addStructuredDocumentTag('checkbox',
[
'sz' => 18,
'fontSize' => 18,
'checked' => true,
'checkedState' => ['font' => 'Wingdings', 'value' => '00FE'],
'uncheckedState' => ['font' => 'Wingdings', 'value' => '006F'],
'sym' => ['char' => '00FE', 'font' => 'Wingdings'],
]
);
Please note that these new features available in the testing branch are only available when LUS is active (https://www.phpdocx.com/updates) If you upgrade your license to phpdocx 14.5 and include LUS on MY PHPDOCX page after login, we can send it to your email address. In this case, please send to contact[at]phpdocx.com if you are using the classic or the namespaces package, and we'll send you the updated class and a sample using it.
Regards.