title: Zend: How to populate data to checkboxes?
body: <p>I am working on zend. I have a form with some checkboxes. I want to get data from database and populate this data to this form. If '1' is stored in table field then tick the check box otherwise leave it alone. In textboxes and dropdowns, data is easily populated but how to check a checkbox in action.</p>
  
  <p>I am creating checkboxes and textboxes elements like this in form.php:</p>
  
  <pre><code>// Person name
  $person = $this-&gt;CreateElement('text', 'name');
  $person-&gt;setLabel('Name');
  $elements[] = $person;    
  
  // Organization name
  $person = $this-&gt;CreateElement('text', 'organization');
  $person-&gt;setLabel('Organization');
  $elements[] = $person;       
  
  // isAdmin Checkbox
  $isAdmin = $this-&gt;CreateElement('checkbox', 'isAdmin');
  $isAdmin-&gt;setLabel('Admin');
  $elements[] = $isAdmin;
  
  $this-&gt;addElements($elements);
  $this-&gt;setElementDecorators(array('ViewHelper'));
  
  // set form decorator (what script will render the form)
  $this-&gt;setDecorators(array(array('ViewScript' , array('viewScript' =&gt; 'organization/accessroles-form.phtml'))));
  </code></pre>
  
  <p>How I render a form:</p>
  
  <pre><code>&lt;form name="myform" action="&lt;?= $this-&gt;element-&gt;getAction() ?&gt;" method="&lt;?= $this-&gt;element-&gt;getMethod() ?&gt;" id="accessrolesform"&gt;
  
  &lt;table align="center" width="100%" border="0"&gt;&lt;tbody&gt;
  
  &lt;tr&gt;
      &lt;td&gt;&lt;?= $this-&gt;element-&gt;name ?&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
      &lt;td&gt;&lt;?= $this-&gt;element-&gt;organization ?&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  
  &lt;tr&gt;
      &lt;td&gt;&lt;?= $this-&gt;element-&gt;isAdmin ?&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And populating data like this (for example):</p>
  
  <pre><code>// Prepare data to populate
  $data['name'] = 'Naveed';
  $data['organization'] = 'ABC';
  $data['isAdmin'] = '1';
  
  // Populate editable data
  $this-&gt;view-&gt;form-&gt;populate( $data );
  </code></pre>
  
  <p>It is populating data in textboxes but not checking the checkbox? Any idea that how to check a checkbox from action? </p>
  
  <p>Thanks</p>