Forum


Replies: 6   Views: 705
How can i insert a checkbox into a table?
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 17-10-2022 - 06:04

Hello,

There's no option to set a custom ID to checkboxes. Also note MS Word removes extra informations added to XML contents that are not included in the OOXML specification.

The best approach would be adding bookmarks with custom names:

$checkboxFragmentA = new WordFragment($docx);
$checkboxFragmentA->addBookmark(array('type' => 'start', 'name' => 'bookmark_a'));
$checkboxFragmentA->addFormElement('checkbox', array('fontSize' => 11,    'defaultValue' => true));
$checkboxFragmentA->addBookmark(array('type' => 'end', 'name' => 'bookmark_a'));

$checkboxFragmentB = new WordFragment($docx);
$checkboxFragmentB->addBookmark(array('type' => 'start', 'name' => 'bookmark_b'));
$checkboxFragmentB->addFormElement('checkbox', array('fontSize' => 11,    'defaultValue' => false));
$checkboxFragmentB->addBookmark(array('type' => 'end', 'name' => 'bookmark_b'));

so you can parse the checkbox next to each bookmark in the XML content and also the HTML output. Also note that in addition to the custom bookmark, the addFormElement method adds another bookmark automatically with its own internal id and name (the internal options of this automatic bookmark can't be customized).

Regards.