The form's filters & validation do not act on the parameters in the request. 
THe request needs to be passed to the form, which populates it's values, and
then tries to validate it, running the filters & the validators:
http://framework.zend.com/manual/en/zend.form.quickstart.html

Do something like:
if ($form->isValid($_POST))
{
echo $form->getValue('searchstr');
// do stuff with validated data ...
}
else
{
 $this->view->formResponse = 'Sorry, there was a problem with your
submission. Please check the following:';
}
$this->view->form = $form;



Also, storing the form in the registry is a very odd thing to do - there may
be a good reason you're doing it, but I can't think of what it might be at
the moment, so think carefully about whether this is hte correct approach.


Might be worth getting a copy of the Zend Framework In Action book, which
has a lot of good stuff & examples about how to put a ZF app together.


Cheers,
Mark


Customize wrote:
> 
> On Fri, Jun 19, 2009 at 12:36 AM,
> lightflowmark<1...@lightflowinterrupted.com> wrote:
>>
>> The filter works fine.
>> $value="z/z";
>> echo str_replace("/", ",", (string) $value); // outputs z,z
>>
>> It's not being run, or you're testing the value before it has run.
>> Impossible to tell from the code you've shared :-)
> 
> Hi,
> 
> I am testing the value in my controller (SearchController). The code
> looks like this:
> 
> class SearchController extends Zend_Controller_Action
> {
>     public function indexAction()
>     {
>         //get the Search Form from registry
>         $registry = Zend_Registry::getInstance();
>         $form = $registry->searchForm;
>         $request = $this->getRequest();
> 
>        $srchstr = $request->getParam('srchstr');
> 
>         Zend_Debug::dump($srchstr);
>               exit;
> 
>     }
> }
> 
> Since my form is displayed in top of each page, I decided to put that
> in layout plus the form's other elements are filled from database.
> Instead of filling it on every page flip, I decided fill up at
> bootstrap and put that in registry to preserve the filled values. That
> is why I am getting the form from registry.
> 
> So IFAIK when submit is pressed in my search form, this
> SearchController should kick start. Even before that the filter should
> have done its job so that when I am getting the request string, it
> should be filtered already.
> 
> Where I went wrong?
> 
> Thanks again
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Custom-Filter-Question-tp24076250p24108999.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to