Note that there are some explanatory texts on larger screens.

plurals
  1. POZend_Form : Populate issue on a checkbox with value=0
    primarykey
    data
    text
    <p>I don't understand why this checkbox with value=0 is checked by <code>populate()</code> whereas no data is passed about this checkbox...</p> <p>My form element :</p> <pre><code>$this-&gt;addElement('multiCheckbox', 'etoiles', array( 'filters' =&gt; array('Int'), 'separator' =&gt; '', 'label_placement' =&gt; 'prepend', 'label_class' =&gt; 'caseacocher', 'decorators' =&gt; $decorator_chain, )); $listeEtoiles = array( '0' =&gt;'Sans étoiles', '1' =&gt; '1 étoile"', '2' =&gt; '2 étoiles', '3' =&gt; '3 étoiles', '4' =&gt; '4 étoiles', '5' =&gt; '5 étoiles', ) ; $this-&gt;getElement('etoiles')-&gt;addMultiOptions($listeEtoiles) ; </code></pre> <p>How I populate the form into my controller :</p> <pre><code>$this-&gt;view-&gt;searchForm-&gt;populate($this-&gt;getRequest()-&gt;getPost()) ; </code></pre> <p>What I get when dumping <code>$this-&gt;getRequest()-&gt;getPost('etoiles')</code> : <code>NULL</code></p> <p>What I get for my checkbox : </p> <pre><code>&lt;input id="etoiles-0" type="checkbox" checked="checked" value="0" name="etoiles[]"&gt; </code></pre> <p>I don't get it. How is it possible to get this checkbox checked, whereas there is NO data about <code>etoiles[]</code> ?? I just figured out that my "Int" filter has something to do with it. Should I remove it ? And what if I want to keep this Int filter ?</p> <p>There are no validators. Should I add some ? What about the InArray validator ? My values array uses string indexes because I thought $_POST data were passed as strings. Is it a mistake ?</p> <p>Any comment or help will be appreciated :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload