Hello,
Do you need to add the checkbox in a table created from scratch or using a template?
In both cases you can generate a WordFragment with the checkbox and add it into the table.
For example, a table created from scratch:
// WordFragments
$checkboxFragmentA = new WordFragment($docx);
$checkboxFragmentA->addFormElement('checkbox', array('fontSize' => 11, 'defaultValue' => true));
$checkboxFragmentB = new WordFragment($docx);
$checkboxFragmentB->addFormElement('checkbox', array('fontSize' => 11, 'defaultValue' => false));
// table
$valuesTable = array(
array(
'Content A',
$checkboxFragmentA,
),
array(
'Content B',
$checkboxFragmentB,
)
);
$docx->addTable($valuesTable);
Or filling a table using template methods:
// WordFragments
$checkboxFragmentA = new WordFragment($docx);
$checkboxFragmentA->addFormElement('checkbox', array('fontSize' => 11, 'defaultValue' => true));
$checkboxFragmentB = new WordFragment($docx);
$checkboxFragmentB->addFormElement('checkbox', array('fontSize' => 11, 'defaultValue' => false));
// replace a table in the template
$data = array(
array(
'ITEM' => 'Product A',
'REFERENCE' => $checkboxFragmentA,
),
array(
'ITEM' => 'Product B',
'REFERENCE' => $checkboxFragmentB,
),
);
$docx->replaceTableVariable($data);
If you are using a DOCX template but not template symbols (so you can't use template methods), you can use the insertWordFragment method to set the reference node to insert the WordFragment.
Regards.