Witam serdecznie (IMG:
style_emoticons/default/smile.gif)
Mecze sie z jednym problemem od kilku dni i moze tu znajde pomoc:)
Wiec tak. Tworze sobie klase formularza
class My_Form_AddClient extends Zend_Form{
public $elementDecorators = array( 'ViewHelper',
'Errors',
array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')), array('Label', array('tag' => 'td', 'class' => 'lbl')), );
public $buttonDecorators = array( 'ViewHelper',
array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')), array(array('label' => 'HtmlTag'), array('tag' => 'td', 'placement' => 'prepend')), );
public function init(){
$this->_build();
$this->_setupDefaults();
my_print_r($this->getMessages());
}
protected function _build(){
$this->addElement('text', 'firmname', array( 'decorators' => $this->elementDecorators,
'label' => 'Nazwa firmy:',
'required' => true,
'filters' => array('StringTrim'), )
);
$this->addElement('text', 'firstname', array( 'decorators' => $this->elementDecorators,
'label' => 'First Name:')
);
$this->addElement('text', 'lastname', array( 'decorators' => $this->elementDecorators,
'label' => 'Last Name:')
);
$this->addElement('submit', 'save', array( 'decorators' => $this->buttonDecorators,
'label' => 'Save')
);
}
protected function _setupDefaults(){
$controller = Zend_Controller_Front::getInstance();
$this->setDefaults(array('firmname'=>$controller->getRequest()->getParam('firmname'))); }
public function loadDefaultDecorators(){
$this->setDecorators(array( 'FormElements',
array('HtmlTag', array('tag' => 'table','class'=>'form')), 'Form',
));
}
i teraz - mam problem z tym aby zmienic styl ramki odpowiedniego pola w przypadku kiedy byla podana zla wartosc. Tzn ta ktora nie przeszla validacji. Czy jest to do zrobienia w ZF w miare przystepny sposob ?
Pozdrawiam