0

I have an element that contains this form:

<?php
echo $this->Form->create('PrototypeItem', array(
    'url' => array('instance' => $instance['PrototypeInstance']['slug'])
    , 'class' => 'simple-search'
    , 'action' => '/search'

));
echo $this->Form->input('search', array(
    'label' => 'Search',
    'type' => 'text'
));
echo $this->Form->end('Search');
?>

<!-- code for displaying search results here -->

Previously, the element was called on a page located at site.com/realtor-documents/search, and it worked fine.

However, the designer has asked me to move the search form to site.com/realtor-documents, to eliminate an extra click. So the form is at /realtor-documents now, but when I submit it, it still redirects to /realtor-documents/search. I'd like the results to appear on the same page as the form, /realtor-documents. How can I do that?

Kluny
  • 189
  • 3
  • 17

1 Answers1

0

This is because of 'action' => '/search' , replace it with 'action' => '' so that it sends the result on the same page.

Adeel Raza
  • 628
  • 5
  • 17
  • Or better would be `'action' => $this->action` ([because having a blank `action` is incorrect](http://stackoverflow.com/questions/1131781/is-it-a-good-practice-to-use-an-empty-url-for-a-html-forms-action-attribute-a)) – scrowler Jun 26 '14 at 00:51
  • This doesn't work - I just get a 404. It's an element from a different plugin, so the current action doesn't contain the search logic. – Kluny Jun 26 '14 at 16:17