Quick form - checkbox not getting checked

2.7k Views Asked by At

I have just started learning Quick Form . I want to know how can I create a check box using the add element and then align it at some desired place . This is what i tried :

$form->addElement('checkbox','testCB1', 'Test my check box',array('checked'=>'checked',value =>'10'));

But my checkbox is not checked neither it gets a value of 10 .

Thanks in advance :)

2

There are 2 best solutions below

0
On BEST ANSWER

Call the setChecked() method:

$form->addElement('checkbox','testCB1', 'Test my checkbox',array('value' =>'10'))->setChecked(true);

Reference

0
On