Hello,
You can use the following methods to add form type elements to the document:
- addStructuresDocumentTag: https://www.phpdocx.com/api-documentation/word-content/add-structured-document-tag-Word-document-with-PHP
- addFormElement: https://www.phpdocx.com/api-documentation/word-content/insert-form-element-Word-document-with-PHP
addStructuresDocumentTag contents are added as block contents. addFormElement contents can be added as inline elements, for example:
$selectOptions = array(
'selectOptions' => array('One', 'Two', 'Three', 'Four'),
'fontSize' => 14,
'color' => 'C90000',
'bold' => true,
);
$contentFragment = new WordFragment($docx);
$contentFragment->addFormElement('select', $selectOptions);
$text[] = array(
'text' => 'Text content with a select field: ',
'bold' => true,
);
$text[] = $contentFragment;
$docx->addText($text);
The value of this element can be changed if the DOCX is locked or not. If the DOCX isn't locked you can do double click on the element and use the arrows to set the first value to be displayed reordering the values or adding new ones or removing the existing ones.
Regards.