codeigniter搜索表单错误

I have been trying to figure out what is wrong with my form search form. I have tried to build a basic search form in code igniter. I have built a search form before and I am building it the same way for a different application and I keep getting the

An Error Was Encountered

The action you have requested is not allowed.

This is not very descriptive for troubleshooting. I am using the same config as I did in my last project. So I don't understand why I am getting the above error message.

When I go to the http://www.gaddisweb.com/index.php/childtest/search, the search form displays the view code. Now, I have rules set the the field is required. I click the search button with the field empty and it should give me and error message saying field required.

Instead, I get the above error message. Even If I put anything in the block I get the same error message. I know I am missing something simple but I can't see it.

Controller Code:

    class ChildTest extends CI_Controller {

    public function index(){

        $this->search();

    }
    public function search(){

        $this->load->helper('form');
        $this->load->library('form_validation');

        $this->form_validation->set_rules(array(
                array(
                        'field' => 'keyword',
                        'label' => 'Child Family Name',
                        'rules' => 'required',
                )
        ));
        $this->form_validation->set_error_delimiters('<div class="alert alert-error">', '</div>');

        if(!$this->form_validation->run()){
            $this->load->view('childsearch');       
        }else{
            $keyword = $this->input->post('keyword');
              echo $keyword;    
        }

      }
   }

View Code:

        <div id="search">
      <p></p>

      <form id="search" method = "post" action="">
          <label id="familyname">Child Family Name</label>
          <input type="text" size="20" id="keyword" name="keyword"/>
          <input type="submit" value="Search" />          
      </form>

    </div>

If the block is empty I should get an error message saying so and if there is anything in the block it should be displayed to me on the post action.

Neither is happening.

Thanks for your help.

Answer This is my opinion on what happened. I can't find any documentation that says this but. I was able to achieve what I was trying to do. I had to do a slight rewrite because the difference between the first time I did a search form and the second time was the fact of using the security sessions.

In my opinion, CI when you turn on the sessions will not allow post to the same page. The post data must be passed to another controller and cannot post to the originating controller.

This part was taken out of the original controller above and placed in another that I name childvalidation.

        $this->load->helper('form');
        $this->load->library('form_validation');

        $this->form_validation->set_rules(array(
                array(
                        'field' => 'keyword',
                        'label' => 'Child Family Name',
                        'rules' => 'required',
                )
        ));
        $this->form_validation->set_error_delimiters('<div class="alert alert-error">', '</div>');

        if(!$this->form_validation->run()){
          }

Once I added the childvalidation controller and passed the form data to it, then I was able to complete the search function.

View Code changed to:

          <?php echo validation_errors() . "</br>";?>
          <?php echo form_open('childsearchvalidation'); ?>
          <label id="familyname">Child Family Name</label>
          <input type="text" size="20" id="keyword" name="keyword"/>
          <input type="submit" value="Search" />          
      </form>

Hope this helps someone.