2010年12月9日星期四

Re: [fw-mvc] Zend Form in two columns

Hi Thomas,

for rendering complex forms the default Decorators are not really handy. I prefer to use the view script decorator (http://framework.zend.com/manual/de/zend.form.standardDecorators.html#zend.form.standardDecorators.viewScript) to arrange elements in complex forms.

Regards,
Manuel


Am 09.12.2010 um 18:13 schrieb Thomas List:

>
> Hello,
>
> 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
>

------------------------------------------------
lum GmbH
Universitätsstraße 52
35037 Marburg

Sitz der Gesellschaft: Marburg
Registergericht: Amtsgericht Marburg, HRB 5149
Geschäftsführer: Thomas Mallée

Telefon: +49 6421 1752455
Telefax: +49 6421 1752456
Mobil: +49 178 / 1407472
E-Mail: m.nickel@lum-software.de

没有评论: