I am trying to figure out how to develop a form with the form elements arranged in two columns. I call the form from my the controller and I created the form class as follows:
class Application_Form_Housing extends Zend_Form
{
public function init()
{
// Set the method for the display form to POST
$this->setMethod('post');
$id = new Zend_Form_Element_Hidden('id');
$id->addFilter('Int');
$this->addElement($id);
$this->addElementPrefixPath('App_Validate', 'App/Validate/','validate');
$this -> addElement( 'select', 'types', array(
'label' => '<h1>What type of home do you live in:</h1><br />',
'escape' => false,
'required' => true,
'multiOptions' => array('Existing Home' => 'Existing Home','New Construction' => 'New Construction','Condominium' => 'Condominium',
'Apartment' => 'Apartment'),
'decorators' => array(
'ViewHelper',
'Errors',
array( 'HtmlTag', array( 'tag' => 'dd' ) ),
array( 'Label', array( 'tag' => 'dt', 'escape' => false) )
)
));
$this -> addElement( 'text', 'zip', array(
'label' => '<h1>What is your zipcode:</h1>',
'escape' => false,
'required' => true,
'validators' => array(
array('validator'=>'ZipCodeExists'),
array('validator' => 'StringLength', 'options' => array(
'min' => 5,
'max' => 5,
'messages' => array(
Zend_Validate_StringLength::INVALID => 'Invalid Zip code entered',
Zend_Validate_StringLength::TOO_SHORT => 'Zip code must be at least 5 characters',
Zend_Validate_StringLength::TOO_LONG => 'Zip code must not be more than 5 characters'
)
))),
'decorators' => array(
'ViewHelper',
'Errors',
array( 'HtmlTag', array( 'tag' => 'dd' ) ),
array( 'Label', array( 'tag' => 'dt', 'escape' => false) )
)
));
// Add the submit button
$this->addElement('submit', 'submit', array(
'ignore' => true,
'label' => 'submit',
));
What would I need to do in the Form, or in the addElement fields to get them to show up in two columns, rather than one long column? In order for the submit button to recognize both fields, would that also require a decorator or viewHelper? Any pointers to get me started out in the right direction would be very helpful.
Regards,
Thomas
没有评论:
发表评论