Skip to content

add default state to checkbox inside textRun #1790

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ardabeyazoglu
Copy link

@ardabeyazoglu ardabeyazoglu commented Dec 28, 2019

Description

When using textRun with templates, there is no possibility to set default checkbox state. This commit adds the possibility as shown below.

$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor("template.docx");
$textRun = new \PhpOffice\PhpWord\Element\TextRun();
$cb = $textRun->addCheckBox("test", "  Test Checkbox");
$cb->setDefaultChecked(true);
$templateProcessor->setComplexValue("my_template_parameter", $textRun);

Fixes #1187 #696

Checklist:

  • I have run composer run-script check --timeout=0 and no errors were reported
  • The new code is covered by unit tests (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes

@PowerKiKi PowerKiKi changed the base branch from develop to master November 16, 2022 21:12
@Progi1984
Copy link
Member

@ardabeyazoglu Could you rebase your PR, please ?

@ardabeyazoglu
Copy link
Author

Sure, I just rebased and pushed.

@coveralls
Copy link

coveralls commented Jun 6, 2025

Coverage Status

coverage: 96.758% (+0.001%) from 96.757%
when pulling 1b459e9 on kivateknoloji:develop
into 0ab0b49 on PHPOffice:master.

@ardabeyazoglu ardabeyazoglu reopened this Jun 6, 2025
@ardabeyazoglu
Copy link
Author

Can we merge this now ?

Copy link
Member

@Progi1984 Progi1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, yes. It's on the good way.

Could you test the Word 2007 modification ? And update the changelog, please ?

Thanks

*
* @return self
*/
public function setDefaultChecked(bool $default = true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function setDefaultChecked(bool $default = true)
public function setDefaultChecked(bool $default = true): self

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can i update the changelog ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the test but i dont know why it fails only on 8.2

@Progi1984 Progi1984 added the Status: Waiting for feedback Question has been asked, waiting for response from PR author label Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Waiting for feedback Question has been asked, waiting for response from PR author
Development

Successfully merging this pull request may close these issues.

Setting checkbox value in template
3 participants