Hello,
The replaceListVariable method adds list items to an existing list in a template, removing the placeholder and adding new list items. We think you are using replaceListVariable with a placeholder that it's not in a list. We recommend you to check the included samples and the documentation available on https://www.phpdocx.com/api-documentation/templates/replace-list-variable-Word-document.
If you need to replace a placeholder (that it's not in a list) by a list, you need to use replaceVariableByWordFragment, for example using a template included in the package:
$docx = new CreateDocxFromTemplate('examples/files/TemplateSimpleText.docx');
$itemList = array(
'Line 1',
'Line 2',
'Line 3',
'Line 4',
'Line 5'
);
$listWordFragment = new WordFragment($docx, 'document');
$listWordFragment->addList($itemList, 1);
$docx->replaceVariableByWordFragment(array('MULTILINETEXT' => $listWordFragment));
$docx->createDocx('output.docx');
We recommend you to read the following documentation pages:
- Practical guide about template methods: https://www.phpdocx.com/documentation/practical/adding-content-to-a-template
- Practical guide about WordFragments: https://www.phpdocx.com/documentation/practical/wordfragments-and-wordml
Regards.