duanrui3480
2014-06-23 14:11
浏览 55
已采纳

Codeigniter form-> run()相当于form_validation-> run()?

I'm relatively new to CodeIgniter and this may be an obvious answer, but I am unable to find anything in the documentation.

I know how to use form_validation->run() to validate a form and run some code when it is submitted successfully. What if I wanted to do something with a form that did not require any sort of validation? Is there a form->run() equivalent that returns true when a user submits the form? Something like:

page.php

public function update($id)
{
    $this->load->helper('form');

    if($this->form->run())
    {
        // do some stuff after user has submitted form
    }

}

图片转代码服务由CSDN问答提供 功能建议

我对CodeIgniter相对较新,这可能是一个明显的答案,但我无法在 文档。

我知道如何使用 form_validation-> run()来验证表单并在成功提交时运行一些代码。 如果我想用不需要任何验证的表单做某事怎么办? 是否有 form-> run()等效,当用户提交表单时返回true? 类似于:

page.php

  public function update($ id)
 {
  $ this-> load-> helper('form'); 
 
 if if($ this-> form-> run())
 {
 //在用户提交表单后做一些事情 
} 
 
} 
   
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duansaxf095988 2014-06-23 14:17
    已采纳

    I don't think there exists such method, but you can do it manually For example:

    if ( ! isset($_POST['something']))  // OR $this->input->post('something');
    {
        return false //maybe?
    }
    else
    {
        //$something = $_POST['something'];
        return true //maybe?
    
    }
    
    已采纳该答案
    打赏 评论
  • duanmei1946 2014-06-23 14:18

    A statement like this should work. You just need to check if any post data exists.

    if ($_POST)
    {
     // do something
    } 
    
    打赏 评论

相关推荐 更多相似问题