PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.24k stars 2.69k forks source link

Trouble Interacting with Dropdown FormField #2622

Closed ysd-wilson closed 3 months ago

ysd-wilson commented 3 months ago

Hello all,

I'm using this package to create a Word document with an interactive dropdown form field. Below is a snippet of my code:

$cell = $table->addCell();
$textRun = $cell->addTextRun();
$textRun->addFormField('dropdown')->setEntries(['Choice 1', 'Choice 2', 'Choice 3'])->setValue(1);

However, when the Word document is opened, the dropdown displays the selected value ("Choice 2") but does not allow me to change the selected option interactively.

I want to create a dropdown like this:

I can see the other options when I double click on the field and they appear to be editable, but the interactivity isn't functioning as expected (Can't change option).

I've tried entering Design Mode in Word, but the issue persists. This problem occurs in the default Print Layout view in Word, and I assume it's due to some restrictions on form fields interaction in Word's viewing modes. However, this behavior is counterintuitive for my users.

Has anyone else encountered this issue or have any suggestions on what may be causing this and how to fix it? Any help or pointers would be greatly appreciated!

Thanks in advance!