Jochen
Jochen

Reputation: 1776

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 { ...

Upvotes: 1

Views: 5248

Answers (2)

Radke
Radke

Reputation: 26

$this->formCheckbox instead of $this->formInput was the point in my case, as Nykac pointed out above.

Upvotes: 0

Nandakumar
Nandakumar

Reputation: 1101

Change true as 1 dude,

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

Upvotes: 3

Related Questions