tickCheckboxes

tickCheckboxes

TRIAL / ADVANCED / PREMIUM

Ticks or unticks a checkbox in a Word document.

Description
public tickCheckbox (array $variable [, array $options])

This method allows to modify the state of a checkbox in a Word template. It accepts:

  • legacy checkboxes.
  • Word 2010 checkboxes.

You should tag those checkboxes so they are recognized by phpdocx as follows:

  • Legacy checkboxes:
    • Go to the developers ribbon tab.
    • Select the checkbox you want to tag.
    • Click in the "Properties" option in the "Controls" menu entry.
    • A pop up window will open.
    • Click on "Add Help Text ..." button.
    • Activate in the "Status bar" tab the "type your own" option.
    • Write the variable name surrounded by the template symbol of your choice ($ by default).
  • Word 2010 checkboxes:
    • Go to the developers ribbon tab.
    • Select the checkbox you want to tag.
    • Click in the "Properties" option in the "Controls" menu entry.
    • A pop up window will open.
    • Write the variable name in the "Tag" input text box surrounded by the template symbol of your choice ($ by default).

Word 2010 checkboxes are not correctly visualized in Word 2007 so use them only in case that you are sure that your final users will use Word 2010 or higher.

Parameters

variable

An array with the names of the variables as keys and values '0' or '1' (ticked or unticked respectively).

options

The possible keys and values of this array are:

Key Type Description
firstMatch bool If the variable appears more than once within the Word document and firstMatch is set to true, phpdocx will only replace the first occurrence of the variable within the Word document.
Code samples

Example #1

The resulting Word document looks like:

Release notes
  • phpdocx 15.5:
    • firstMatch option.