Hello,
There's no direct method to get all input fields or merge fields. These are complex elements that contain a lot of information. For example, in the case of structure document tags (w:sdt): alias, tag, text contents, styles, id...
The best approach for this specific case is using getDOCXPathQueryInfo. For example, to return the tag value of all w:sdt elements:
$docx = new CreateDocxFromTemplate('template.docx');
// query w:sdt/w:sdtPr elements
$referenceNode = array(
'customQuery' => '//w:sdt//w:sdtPr'
);
$foundNodes = $docx->getDOCXPathQueryInfo($referenceNode);
if (count($foundNodes['elements']) > 0) {
$inputFieldNodes = array();
// iterate the elements to get the needed information
foreach ($foundNodes['elements'] as $nodes) {
$tagNodes = $nodes->getElementsByTagName('tag');
if ($tagNodes->length > 0 && $tagNodes->item(0)->hasAttribute('w:val')) {
$inputFieldNodes[] = $tagNodes->item(0)->getAttribute('w:val');
}
}
print_r($inputFieldNodes);
}
And a very similar approach can be used for merge fields.
Regards.