Hello,
For my zend form I would like a month drop down and a year drop down.
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.
I could accomplish this by setting no label on the year and then doing some css trickery, but I'd like a cleaner solution.
Edit, Final Code:
public function init($options=array()) {
$this->setName('add');
$this->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->setLabel("Name On Card")->setIgnore(false)->setRequired(true);
$number->setLabel("Card Long Number")->setIgnore(false)->setRequired(true);
$cvv->setLabel("CVV2")->setIgnore(false)->setRequired(true);
$expiry_month->setMultiOptions($months);
$expiry_year->setMultiOptions($years);
$amount->setLabel("Amount")->setIgnore(false)->setRequired(true)->setMultiOptions($amounts);
$submit->setLabel("Submit")->setIgnore(true);
$this->addElements(array($name, $number, $cvv, $expiry_month, $expiry_year, $amount, $submit));
$this->addDisplayGroup(array('expiry_month', 'expiry_year'), 'Expires');
}
and if its helpful to anyone, I don't think you can set a label, but you can set a fieldset title via:
$this->addDisplayGroup(array('address', 'city', 'state', 'country', 'zip'), 'Address', array('legend' => 'Billing Address'));