Note that there are some explanatory texts on larger screens.

plurals
  1. POZend_Form Multiple dropdown as one value
    primarykey
    data
    text
    <p>For my zend form I would like a month drop down and a year drop down.</p> <p>I would like them to appear next to each other. Its okay for them to be separate elements in the zend_form and combine and check them in the controller, but for the design I would like them to sit right next to each other.</p> <p>I could accomplish this by setting no label on the year and then doing some css trickery, but I'd like a cleaner solution.</p> <p>Edit, Final Code: </p> <pre><code>public function init($options=array()) { $this-&gt;setName('add'); $this-&gt;setMethod('post'); $name = new Zend_Form_Element_Text('name'); $number = new Zend_Form_Element_Text('number'); $cvv = new Zend_Form_Element_Text('cvv'); $expiry_month = new Zend_Form_Element_Select('expiry_month'); $expiry_year = new Zend_Form_Element_Select('expiry_year'); $amount = new Zend_Form_Element_Select('amount'); $submit = new Zend_Form_Element_Submit('Submit'); $amounts = self::load_amounts(); $months = self::load_months(); $years = self::load_years(); $name-&gt;setLabel("Name On Card")-&gt;setIgnore(false)-&gt;setRequired(true); $number-&gt;setLabel("Card Long Number")-&gt;setIgnore(false)-&gt;setRequired(true); $cvv-&gt;setLabel("CVV2")-&gt;setIgnore(false)-&gt;setRequired(true); $expiry_month-&gt;setMultiOptions($months); $expiry_year-&gt;setMultiOptions($years); $amount-&gt;setLabel("Amount")-&gt;setIgnore(false)-&gt;setRequired(true)-&gt;setMultiOptions($amounts); $submit-&gt;setLabel("Submit")-&gt;setIgnore(true); $this-&gt;addElements(array($name, $number, $cvv, $expiry_month, $expiry_year, $amount, $submit)); $this-&gt;addDisplayGroup(array('expiry_month', 'expiry_year'), 'Expires'); } </code></pre> <p>and if its helpful to anyone, I don't think you can set a label, but you can set a fieldset title via:</p> <pre><code>$this-&gt;addDisplayGroup(array('address', 'city', 'state', 'country', 'zip'), 'Address', array('legend' =&gt; 'Billing Address')); </code></pre>
    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.
 

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