tread
tread

Reputation: 11098

Zend Ajax Validation returning a positive messages?

I have looked at the Zendcast here. It explains how to make use of Ajax validation very well.

It returns the errors as expected, however I would like to return a tick or some positive indicator when the validation does not return an error. However the response returned only gives the zend form errors:

        $f = new Form_Test();
        $f->isValid($this->_getAllParams());
        $this->_helper->json($f->getMessages());

How could I return a positive message in the array?

Upvotes: 0

Views: 31

Answers (1)

Volvox
Volvox

Reputation: 1649

Maybe it would be easier to just check in JS if there is error for selected field nd if not then check it as ok?

You can also try using $f->getErrors() as it will return you array with all elements and their errors (or empty array if there is no error for selected element). But this will return only short version of message, not full description so you would have to translate it to full message manually.

You can also create your own array with simple foreach loop:

    $errors = array();
    foreach($f->getElements() as $e){
        $errors[$e->getName()] = $e->getMessages();
    }

Upvotes: 1

Related Questions