Note that there are some explanatory texts on larger screens.

plurals
  1. POZend Framework 2: Trying to add a selectbox to a form does not render values
    primarykey
    data
    text
    <p>I am trying to add a selectbox to one of my forms (which just with input type="text" elements are working pretty good) but all I get is just an empty selectbox with none tags in it. So this is the code I use:</p> <p>Bla.php :: Bla->getInputFilter()</p> <pre><code>$inputFilter-&gt;add($factory-&gt;createInput(array( 'type' =&gt; 'Zend\InputFilter\Select', 'name' =&gt; 'payment_type', 'required' =&gt; true, 'filters' =&gt; array( array('name' =&gt; 'Int'), ), ))); </code></pre> <p>BlaForm.php :: BlaForm->__construct():</p> <pre><code>$this-&gt;add(array( 'type' =&gt; 'Zend\Form\Element\Select', 'name' =&gt; 'payment_type', 'options' =&gt; array( 'label' =&gt; 'Payment', 'value_options' =&gt; array( 0 =&gt; 'Nur Überweisung', 1 =&gt; 'Nur Paypal', 2 =&gt; 'Nur Barzahlung im Voraus', ), ), 'attributes' =&gt; array( 'value' =&gt; 0 //set selected to "Nur Überweisung" ) )); </code></pre> <p>bla.php (View)</p> <pre><code>&lt;div class="control-group"&gt; &lt;?php echo $this-&gt;formLabel($form-&gt;get('payment_type')-&gt;setLabelAttributes(array( 'class' =&gt; 'control-label' ))); ?&gt; &lt;div class="controls"&gt; &lt;?=$this-&gt;formElement($form-&gt;get('payment_type'));?&gt; &lt;span class="help-inline"&gt;&lt;?=$this-&gt;formElementErrors($form-&gt;get('payment_type'));?&gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I already tried using "options" instead of "value_options" and yesterday I learned that it is just an alias of "value_options". Also I tried formSelect() instead of formElement() in my view but that doesn't change anything either. I even removed the umlauts from the strings for testing purposes...</p> <p>Did anybody experience the same problem or has any idea, what I am currently doing wrong?</p>
    singulars
    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.
 

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