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

  • Home
  • SEARCH
  • 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 1052721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:08:20+00:00 2026-05-16T17:08:20+00:00

I’ve set up a page that displays server logs and added a filter form

  • 0

I’ve set up a page that displays server logs and added a filter form so I can filter the logs on specific actions, dates, etc. I can’t seem to figure out how to use CPagination to split the results into pages, however. If I add the CPagination widget, when a page is selected from the widget, the filter form isn’t resubmitted and my filter results are lost.

I’m at a loss for a simple solution to maintain my filter form data with the CPagination widget. Any suggestions would be great.

Update
I have this functioning but I had to set a session state to maintain my form data.

$filter=false;
$form=new LogFilterForm;
if(isset($_POST['LogFilterForm'])){
    $form->attributes=$_POST['LogFilterForm'];
    Yii::app()->user->setState('filter',$form);
    $filter=true;
}
else if(Yii::app()->user->hasState('filter')){
    $form=Yii::app()->user->getState('filter');
    $filter=true;
}

Any ideas on how I can clear the session state on navigation to another page?

  • 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-05-16T17:08:21+00:00Added an answer on May 16, 2026 at 5:08 pm

    If you were using CGridView it would be easy to add filters with paging – it’s built in. Just look at the admin.php view rendered by the Gii crud tool (or the blog demo maybe too). Perhaps you don’t want to display the logs in table form though.

    Instead of setting session variables you could make the form a stateful form and save the previous state using setPageState(). I don’t know if the pagination submits the form though… you might have to bind a jQuery event to submit the form when clicking on the pagination links. That would be kinda ugly if you had to do that.

    As for clearing the session state variables, my only idea right now is to override onBeginRequest() or something to check if the user is on the search page, and if they aren’t, then clear the session variable. You could just leave it too – set a short expiration date and forget it. Or save it to your database instead of the session? 😛

    EDIT

    If you go the route of overriding onBeginRequest() it looks like it’s as easy as declaring a callback in the config file. More info here in the Yii forums, and here too. I’ve never actually done it myself though. Good luck!

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

Sidebar

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.