Forum


Replies: 3   Views: 1134
How do i create an inline combobox?
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 27-01-2021 - 15:30

Hello,

You can use the following methods to add form type elements to the document:

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.