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
=======================

Reply via email to