Search code examples
zend-framework2

How to set checkbox value to checked in zend framework 2?


I am wondering how to set the checkbox value of a zend form element to 'checked'? I went in my Debug-11-condition so I would expect to see an active arrow in my box. Unfortunately the box remains empty.

$room = $this->getRoomTable()->getRoom($roomId);
$roomForm->bind($room);
$lightOneValue = $room->getLighsone();
if ($lightOneValue == "100"){
    Debug::dump('11');
    $roomForm->get('lightone')->setChecked(true);
} else { ...

Solution

  • Change true as 1 dude,

       $roomForm->get('lightone')->setValue(1);