Skip to content

Tempate - Modify checkbox value #1929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
poitierjohan opened this issue Sep 6, 2020 · 4 comments
Closed

Tempate - Modify checkbox value #1929

poitierjohan opened this issue Sep 6, 2020 · 4 comments
Milestone

Comments

@poitierjohan
Copy link

Hi,
I have in my template *.docx an input type CheckBox.
But, I want to modify this value for my final document.
Is that possible ?
Actually, i use a Wingdings text.
Thank you for your answers...

@ozilion
Copy link
Contributor

ozilion commented Sep 6, 2020

Hi,

As i commented your previous issue here https://github.com/PHPOffice/PHPWord/issues/1791#issuecomment-569919076 you can modify state of checkbox in your teamplates. Also you can use my modifed TemplateProcessor.php file it's for v0.17 so no need to change your file if you are using latest version. And sending an example template docx includes several checkboxes that i use.

template.docx

TemplateProcessor.zip

@poitierjohan
Copy link
Author

poitierjohan commented Sep 17, 2020 via email

@Blue-QAQ
Copy link

使用setvalue()可以达到这个效果,只需要把你替换的值改成xml代码,例如:
setvalue("checkBox1",<w:sdt><w:sdtPr><w:rPr><w:rFonts w:eastAsia="华文仿宋" w:hint="eastAsia" /><w:sz w:val="21" /></w:rPr><w:id w:val="-310866052" /><w15:appearance w15:val="hidden" />w14:checkbox<w14:checked w14:val="1" /><w14:checkedState w14:val="0052" w14:font="Wingdings 2" /><w14:uncheckedState w14:val="00A3" w14:font="Wingdings 2" /></w14:checkbox></w:sdtPr><w:sdtContent><w:r><w:rPr><w:rFonts w:eastAsia="华文仿宋" w:hint="eastAsia" /><w:sz w:val="21" /></w:rPr><w:sym w:font="Wingdings 2" w:char="F0A3" /></w:r></w:sdtContent></w:sdt>);
然而关于这个代码你需要自己去修改docx的扩展名,改成ZIP后再打开里面的document.xml你就能看到xml代码了,你可以新建一个只有一个复选框的文档,然后找到对应的代码,就可以进行替换了。

@Progi1984
Copy link
Member

Fixed by #2509

@Progi1984 Progi1984 added this to the 1.2.0 milestone Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants