Great, I found the problem and the solution. So if anyone is interested in
it... here it is:

class MyForm extends Zend_Form
{
// the decorators
public $formDecorators = array(
    'FormElements',
    'Form'
);
public $elementDecorators = array(
    'ViewHelper',
    'Errors',
    array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' =>
'element')),
    array('Label', array('requiredSuffix' => ' *', 'tag' => 'td', 'style' =>
'width: 225px;')),
    array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
);
public $groupDecorators = array(
  'FormElements',
  array('HtmlTag', array('tag'=>'table')),
  'Fieldset'
);

// the construct
public function __construct($action = '#', $description = '')
{
  parent::__construct ( $action, $description );

  $this->setAttrib('accept-charset', 'UTF-8');
  $this->setAction($action)
         ->setMethod('post')
         ->setDecorators($this->formDecorators)
         ->setDisableLoadDefaultDecorators(true);
  $this->setName('formname');
  $this->setAttrib('enctype', 'multipart/form-data');

  $formElements[] = self::createElement('text', 'field1')
                        ->setLabel('field 1')
                       ->setDecorators($this->elementDecorators);
  $formElements[] = self::createElement('text', 'field2')
                        ->setLabel('field 2')
                       ->setDecorators($this->elementDecorators);

  self::addElements($formElements);
  self::addDisplayGroup(
    array('field1','field2'),
    'main', 
    array(
      'disableLoadDefaultDecorators' => true,
      'decorators' => $this->groupDecorators,
      'legend' => 'Basisgegevens'
    )
  );

  /*
  *  Repeat here everything to add fields to other DisplayGroups
(createfields, addelements, 
  *  adddisplaygroup)
  */

  $submit = self::createElement('submit', 'submit');
  self::addElement($submit);
}
}

! also hidden fields need to be added to a displaygroup unless you add them
all at the and like I did with the submit button.

-----
visit my website at  http://www.phpscriptor.com/ http://www.phpscriptor.com/ 
-- 
View this message in context: 
http://www.nabble.com/zend-form-decorators-tp21054571p21058134.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to