Or how i can change attributes only for elements, where validation failed. ?

I have 10 elements.
class myForm extends Zend_Form
....
//1
$selecopt1 = new Zend_Form_Element_Select('selecopt1');
$selecopt1->setAttrib('class','fInput')
                ->addDecorators(array(
                    array('HtmlTag', array('tag' => 'div','class' => 'data')),
                    array('Label', array('' => '')),
                ));
//2
$text_in1 = new Zend_Form_Element_Text('text_in1');
$text_in1->setAttrib('id','stevilo')
                  ->setAttrib('class','fInput')
                  ->setAttrib('title','something,...')
                  ->addDecorators(array(
                            array('HtmlTag', array('' => '')),
                            array('Label', array('' => '')),
                        ));
//3
$text_in2 = new Zend_Form_Element_Text('text_in2');
$text_in2->setAttrib('id','stevilo1')
                        ->setAttrib('class','fInput')
                        ->setAttrib('title','You can,....')
                        ->addDecorators(array(
                            array('HtmlTag', array('' => '')),
                            array('Label', array('' => '')),
                        ));
...
and so on,...

in controller.
//if i want to validate whole form i do something like this.

if ($this->_request->isPost()) 
{
         $form->selectopt1->addValidator('CheckOpti')
                                    ->setAttrib('class,'NORMAL');

         $form->text_in1->addValidator('CheckTx1')
                                 ->setAttrib('class,'NORMAL')
                                ->setAllowEmpty(false);

         $form->text_in2->addValidator('CheckTx2')
                                 ->setAttrib('class,'NORMAL')
                                 ->setAllowEmpty(false);

  if ( $form->isValid($formData)
  {
      //if OK
      return $this->_forward('izracun');  //go to izracunAction...
  } 
   else 
  {
  // if not OK
         $form->selectopt1->setAttrib('class,'ERROR');
         $form->text_in1->setAttrib('class,'ERROR');
         $form->text_in2->setAttrib('class,'ERROR');

  }

But if is mistake only in text_in1, this is not change class only for
text_in1 (but for all elements). 
How i can do validation of any element i want?
-- 
View this message in context: 
http://www.nabble.com/How-to-validate-just-one-element-of-form--tp16721005p16721005.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to