Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8050221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:00:39+00:00 2026-06-05T07:00:39+00:00

I have a simple search form (site/search.php) to send search string to controller and

  • 0

I have a simple search form (site/search.php) to send search string to controller and show search result if available. I’m using CGridView to show data.
UPDATE Here is my view (site/search.php) file:

     <form name="quickSearchForm" action="<?php echo Yii::app()->createUrl("site/search"); ?>" method="POST">
          <div data-role="fieldcontain">
              <input type="search" name="searchText" id="searchText" value="<?php echo $searchText; ?>"/>
              <input type="submit" name="submitBtn" id="submitBtn" value="search"/>
                    <a href="#">Advanced</a>
           </div>
     </form>


<?php 
   if (!empty(itemList)) {
        $this->widget('zii.widgets.grid.CGridView', array(
            'id'=>'task-grid',
            'dataProvider'=>$itemList,
            'pager'=>array(
                'header'         => '',
                'firstPageLabel' => '&lt;&lt;',
                'prevPageLabel'  => '&lt;',
                'nextPageLabel'  => '&gt;',
                'lastPageLabel'  => '&gt;&gt;',
            ),
            'template'=>'{pager}{items}{pager}',
            'columns'=>array(
                array(
                    'name'  => 'name',
                    'value' => '$data->name',
                ),
                array(
                    'name'  => 'date',
                    'value' => 'date("d/m/Y",strtotime($data->date) )',   
                ),
             ),
        ),);
     } //end if
?>

At controller, I’m using $searchText to get data with CActiveDataProvider then render back to search.php.

  <?php       
        $this->render($view = "search", array(
            'searchText'    => $searchText,
            'itemList'       => $itemListBySearch,
            'taskResult'    => $tasks,

        ));

END UPDATE

My problem is $itemList has many item, GridView will paginate. But, I click on button page [2], browser direct to r=site/search&page=2 and itemList lost!

May I use ajax instead direct to r=site/search&page=2???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:00:42+00:00Added an answer on June 5, 2026 at 7:00 am

    Yii pager’s default implementation preserves all GET values from the request, but your search form is using POST, so search term aren’t included in pagination links. Try to change form method to GET and you’ll get desired behavior:

    <?php echo CHtml::beginForm(array('site/search'), 'get'); ?>
    

    PS: IMHO search forms should always use GET method to send search options, because it provides ability to copy URL which holds all search terms, and then send it to someone else (for example to developers) or save it for further reproduction of the same request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a kase model which I am using a simple search form in.
I have a simple search form <form id=search name=search method=GET action=search.php enctype=application/x-www-form-urlencoded> But this
i have a php dynamic website with a simple mysql search form which means
I have a simple search form with a box and a button. <form action
I'm making a simple search form in rails. In my search view I have
I have a simple search field on a form that is set as multiline
I have a simple form like this: <form name=serachForm method=post action=/home/search> <input type=text name=searchText
I need a simple search form on my Drupal site but I can't figure
I have written a simple mysql search form that searches between two dates. This
I am using jQuery datatables in a dynamic PHP site. I have a page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.