Skip to content
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

default value checked on checkbox #281

Closed
ahrinal opened this issue Jun 16, 2014 · 6 comments
Closed

default value checked on checkbox #281

ahrinal opened this issue Jun 16, 2014 · 6 comments

Comments

@ahrinal
Copy link

ahrinal commented Jun 16, 2014

hii all.
i want to create a checkbox with a default value checked in one of that like this
untitled

so, is there any function to do that??
thanks so much..

@Progi1984 Progi1984 added this to the 0.12.0 milestone Jun 16, 2014
@ivanlanin ivanlanin self-assigned this Jun 17, 2014
@ivanlanin
Copy link
Contributor

Use the new FormField element on the develop branch.

$textrun = $section->addTextRun();
$textrun->addFormField('checkbox');
$textrun->addText('D');

$textrun = $section->addTextRun();
$textrun->addFormField('checkbox')->setValue(true);
$textrun->addText('B');

@ahrinal
Copy link
Author

ahrinal commented Jun 17, 2014

helpful answers and so fast response
hatur nuhun kang ivan :)

@ahrinal
Copy link
Author

ahrinal commented Jun 17, 2014

oh iya maaf 1 lagi kang. kalo di masukan ke dalam tabel seperti apa ya??beda seperti yang ini :
$table->addCell(1000)->addCheckBox('chkbox1','pertama');

@ivanlanin
Copy link
Contributor

You need to change the container from section to cell (punten nganggo basa Inggris supados nu sanesna ngartos):

$table = $section->addTable();
$cell = $table->addRow()->addCell(1000);

$textrun = $cell->addTextRun();
$textrun->addFormField('checkbox');
$textrun->addText('D');

$textrun = $cell->addTextRun();
$textrun->addFormField('checkbox')->setValue(true);
$textrun->addText('B');

@ahrinal
Copy link
Author

ahrinal commented Jun 18, 2014

wish Allah always bless you. my job much helped.
nuhun... :)

@sunildora94
Copy link

sunildora94 commented Nov 26, 2018

Use this to add the checked checkbox to the word document,

$table = $section->addTable();
$cell = $table->addRow()->addCell(1000);

$textrun = $cell->addTextRun();
$textrun->addFormField('checkbox');
$textrun->addText('D');

$textrun = $cell->addTextRun();
$textrun->addFormField('checkbox')->setValue('<w:sym w:font="Wingdings" w:char="F0FE"/>');
//This is for adding a checked checkbox
$textrun->addText('B');`

This did work for me, hope this will help you guys. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants