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 7436213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:12:09+00:00 2026-05-29T10:12:09+00:00

i have the following search form <?php echo $this->Form->create(‘Order’, array(‘action’ => ‘search’,’type’=>’get’));?> <?php echo

  • 0

i have the following search form

<?php
echo $this->Form->create('Order', array('action' => 'search','type'=>'get'));?>
<?php echo $this->Form->input('SearchTerm',array('label' => 'Find:')); ?>
<?php $options=array('full_name'=>'By Name','code'=>'By Code','phone'=>'By Phone','email'=>'By Mail'); ?>
<?php echo $this->Form->input('options', array('type'=>'select', 'label'=>'Search:', 'options'=>$options)); ?>

<?php echo $this->Form->end('search'); ?>  

<?php if($rs!=0){?>
<?php if($rs!=null) { ?>
    results found : <?php print $results; //print_r ($result['Order']['full_name']); ?>
<h1 class="ico_mug">Results Matching Term: <?php print '"'.$term.'"' ;?></h1>
<table id="table">
    <tr>

        <th>Client Name</th>
        <th>Order Code</th>
        <th>Phone</th>
        <th>Received Order</th>
        <th>Working On Order </th>
        <th>Order Ready </th>
    </tr>

    <!-- Here is where we loop through our $posts array, printing out post info -->

    <?php foreach ($rs as $order): ?>
    <tr>

        <td>
            <?php echo $this->Html->link($order['Order']['full_name'],
            array('controller' => 'orders', 'action' => 'view', $order['Order']['id'])); ?>
        </td>
        <td><?php echo $order['Order']['code']; ?></td>
        <td><?php echo $order['Order']['phone']; ?></td>
        <td><?php echo $this->OrderStatus->getStatusString($order['Order']['receive_state']); ?></td>
        <td><?php echo $this->OrderStatus->getStatusString($order['Order']['working_state']); ?></td>
        <td><?php echo $this->OrderStatus->getStatusString($order['Order']['ready_state']); ?></td>
        <td> <?php //echo $this->Html->link($this->Html->image("cancel.jpg"), array('action' => 'index'), array('escape' => false));?><?php echo $this->Html->link($this->Html->image("edit.jpg"), array('action' => 'edit',$order['Order']['id']), array('escape' => false));/*echo $this->Html->link('Edit', array('action' => 'edit', $order['Order']['id']));*/?></td>
    </tr>
    <?php endforeach; ?>
    <tr ><?php //echo $this->Paginator->numbers(array('first' => 'First page')); ?></tr>
    <?php
    $urlParams = $this->params['url'];
    unset($urlParams['url']);
    $optionss=array('url' => array('?' => http_build_query($urlParams)));
    //$this->Paginator->options($optionss);
    $this->Paginator->settings['paramType'] = 'querystring';

    ?>

    <tr ><?php  //echo" << ".$this->Paginator->counter(
       // 'Page {:page} of {:pages}');
        ?></tr>

</table>

 <?php }else echo"no results found"; ?>


<?php } //endif?>

and this is my controller action

function search($options=null){
        $this->set('results',"");
        $this->set('term',"");
        $this->set('rs',0);    

        if ((isset($_GET["SearchTerm"]))||(isset($_GET["options"])) ) {
            $SearchTerm=$_GET["SearchTerm"];
            $options=$_GET["options"];

            if (!$options || !$SearchTerm) {
                $this->Session->setFlash('Please enter something to search for');
            }
            else {
                $SearchArray = array($options." LIKE " => "%".$SearchTerm."%");

                $this->paginate = array('conditions' =>  $SearchArray,'limit'=>2,'convertKeys' => array($options, $SearchTerm));
                $data=$this->paginate('Order');
                $this->set('rs', $data);
                $this->set('term',$SearchTerm);

            }
        }

as you can see i am using Get parameters options and SearchTerm. I want theese two to stay in the pagination links. I have tried various fixes that i’ve found on stackoverflow and on other site, (like ex:

$urlParams = $this->params['url'];
    unset($urlParams['url']);
    $optionss=array('url' => array('?' => http_build_query($urlParams)));

yet i still get the following error message :

Indirect modification of overloaded property
PaginatorHelper::$settings has no effect
[APP\View\orders\search.ctp, line 75

why is that? and what about a solution to this ? ( even if i use the wxample from the cookbook

$this->Paginator->settings[‘paramType’] = ‘querystring’;

i still get the same error :S can you please help/explain ?

  • 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-29T10:12:09+00:00Added an answer on May 29, 2026 at 10:12 am

    If I understand your code correctly, you should be able to replace:

    <?php
        $urlParams = $this->params['url'];
        unset($urlParams['url']);
        $optionss=array('url' => array('?' => http_build_query($urlParams)));
        //$this->Paginator->options($optionss);
        $this->Paginator->settings['paramType'] = 'querystring';
    ?>
    

    with

    <?php $this->Paginator->options(array('url' => $this->passedArgs)); ?>
    

    Form Fields In Pagination
    If you are actually trying to put the form elements into the pagination, you will need to alter your code slightly. You will need to build named parameters for each item in the search options. Then, in the action of the controller, you will need to check for both the request->data and the params[‘named’] versions of the search to make sure you use them in both cases. I would also clean up the code so it is a little more readable.

    First, you need to use the cake methods for getting the data. It will make sure that it cleans the requests for you etc. In addition, you will need to account for the search term and filter options being passed as both a named variable and submitted in a form. So you need to update your controller as follows:

    function search($options=null){
    
        $this->set('results',""); // where is this used ??
        $this->set('rs', 0); 
        $this->set('SearchTerm', '');
        $this->set('FilterBy', '');   
        $this->set('options', array('full_name'=>'By Name','code'=>'By Code','phone'=>'By Phone','email'=>'By Mail'));
    
        if ($SearchTerm = $this->request->data['Order']['SearchTerm']) or $SearchTerm = $this->params['named']['SearchTerm']) {
            if ($FilterBy = $this->request->data['Order']['FilterBy'] or $FilterBy = $this->params['named']['FilterBy'])) {
                $this->paginate = array(
                    'conditions' => array($FilterBy." LIKE " => "%".$SearchTerm."%"), 
                    'limit' => 2, 
                    'convertKeys' => array($FilterBy, $SearchTerm)
                );
                $this->set('rs', $this->paginate('Order'));
                $this->set('SearchTerm', $SearchTerm);
                $this->set('FilterBy', $FilterBy);
            } else {
                $this->Session->setFlash('Please enter something to search for');
            }
        } else {
            $this->Session->setFlash('Please enter something to search for');
        }
    }
    

    Next, we focus on the view. Remove move this:

    $options=array('full_name'=>'By Name','code'=>'By Code','phone'=>'By Phone','email'=>'By Mail');
    

    It shouldn’t be in the view. It belongs in the controller (which is where it is now).

    Next, cleanup the form:

    <?php
      echo $this->Form->create('Order', array('action' => 'search','type'=>'get'));
      echo $this->Form->input('SearchTerm',array('label' => 'Find:'));
      echo $this->Form->input('FilterBy', array('type'=>'select', 'label'=>'Search:', 'options'=>$options));
      echo $this->Form->end('search'); 
    ?>  
    

    *Note that I changed the options name to FilterBy so it is easier to find in the controller. Also there are other things that could be cleaned up in the view. However, I will only address the things that correspond to the question.

    Now you need to replace this code:

    <tr ><?php //echo $this->Paginator->numbers(array('first' => 'First page')); ?></tr>
        <?php
        $urlParams = $this->params['url'];
        unset($urlParams['url']);
        $optionss=array('url' => array('?' => http_build_query($urlParams)));
        //$this->Paginator->options($optionss);
        $this->Paginator->settings['paramType'] = 'querystring';
    
        ?>
    
        <tr ><?php  //echo" << ".$this->Paginator->counter(
           // 'Page {:page} of {:pages}');
            ?></tr>
    
    </table>
    

    With this code:

    </table>
    <p>
    <?php
      $this->Paginator->options(array('url' => array_merge(array('SearchString' => $SearchString, 'FilterBy' => $FilterBy), $this->passedArgs)));
    
    echo $this->Paginator->counter(array(
    'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%')
    ));
    ?>  
    </p>
    
    <div class="paging">
        <?php echo $this->Paginator->prev('<< ' . __('previous'), array(), null, array('class'=>'disabled'));?>
     |  <?php echo $this->Paginator->numbers();?>
     |  <?php echo $this->Paginator->next(__('next') . ' >>', array(), null, array('class' => 'disabled'));?>
    </div>
    

    You an format it differently of course to fit your needs. But the code should work as expected with the search term and filter option applied to pagination.

    Good luck and Happy Coding!

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

Sidebar

Related Questions

I currently have the following code: <form action=process.php method=POST> <fieldset class=form-search> <input type=text class=input-text
I have the following code: <form action=search.php method=get name=searchprod id=prodsearch> <table border=0 cellpadding=0 cellspacing=0>
I have the following code: $(#auto).autocomplete({ source: js/search.php, minLength: 3 }); This code is
for the following form <form action ='search.php' method = 'post'> <select name=filter> <option id=A
I have a really simple search form with the following Label (Search) Textbox (fixed
I have the following code: <?php function search_reset() { $query = $_GET['q']; if($query) echo
I have the following form that uses a GET to pass parameters to a
I have the following PHP array: Array ( [0] => 750 [1] => 563
I have a web page configured with the search form in one php page
I have the following controller: public ActionResult Search(string Name, int? Friend, int? Page) It

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.