Try this:

$this->getPost('qsearch');


Deepak Shrestha wrote:
> 
> Hi,
> 
> I am trying to implement a simple search function. For the test
> purpose I am trying to display the search string in my view. This is
> how it looks like:
> 
> my form
> --------------------------
> class Form_Search extends Zend_Form
> {
>     public function init()
>     {
>         //create search text input element
>         $qsearch = New Zend_Form_Element_Text('qsearch');
>         $qsearch ->setLabel('Quick Search');
>         $qsearch ->setAttrib('size', '40');
>         $qsearch ->setRequired(true);
>         $qsearch ->addFilter('StringTrim');
>         $qsearch ->addValidator('NotEmpty',true);
>         $qsearch ->addValidator('Alnum', true);
>         $qsearch ->addErrorMessage('Invalid search string');
> 
>         // add the submit button
>         $submit = New Zend_Form_Element_Submit('submit');
>         $submit->setLabel('Search');
> 
>         //add the elements to form
>         $this->addElements(array($qsearch, $submit));
>     }
> 
> }
> ----------------------------------------------
> 
> 
> my controller
> ---------------------------------------------
>     public function indexAction()
>     {
> 
>         $request = $this->getRequest();
>         $form = $this->_getSearchForm();
> 
> 
>         $this->view->form = $form;
> 
> 
>         if($request->isPost())
>         {
>             if ($form->isValid($request->getPost()))
>             {
>                 $strinput = $form->getValue('qsearch');
>                 $this->showQuickSearchResult($strinput);
> 
>             }
> ...
> ...
> 
>     private function showQuickSearchResult($searchstr)
>     {
>         $this->view->searchstr = $searchstr;
>     }
> 
> -----------------------------------------------------------------
> 
> 
> my view script
> -------------------------------
>     <div id="quicksearch">
>         <?= $this->form ?>
>     </div>
> 
>     <div id="check">
>         <? if ($this->searchstr): ?>
>             <h2>search string is: <? $this->searchstr ?></h2>
>         <? endif ?>
>     </div>
> -----------------------------
> 
> 
> 
> My problem is the search string I entered in the form doesn't get
> shown. Its blank.
> 
> Why?
> 
> What's wrong with this code?
> 
> Isn't this how we get the value from the Form?
> -------------------------------
> $form->getvalue(<element_name>);
> -------------------------------
> 
> Thanks
> 
> 
> -- 
> =======================
> Registered Linux User #460714
> Currently Using Fedora 8, 10
> =======================
> 
> 


-----
visit my website at  http://www.phpscriptor.com/ http://www.phpscriptor.com/ 
-- 
View this message in context: 
http://www.nabble.com/Why-%24form-%3EgetValue%28%29-is-not-working--tp21868209p21870398.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to