【问题标题】:Codeigniter form->run() equivalent to form_validation->run()?Codeigniter form->run() 等价于 form_validation->run()?
【发布时间】:2014-06-23 14:11:56
【问题描述】:

我对 CodeIgniter 比较陌生,这可能是一个显而易见的答案,但我在文档中找不到任何内容。

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

page.php

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

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

}

【问题讨论】:

  • 只需要检查是否有$_POST即可。

标签: php forms


【解决方案1】:

我认为不存在这种方法,但是您可以手动进行 例如:

if ( ! isset($_POST['something']))  // OR $this->input->post('something');
{
    return false //maybe?
}
else
{
    //$something = $_POST['something'];
    return true //maybe?

}

【讨论】:

    【解决方案2】:

    这样的陈述应该有效。您只需要检查是否存在任何帖子数据。

    if ($_POST)
    {
     // do something
    } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-25
      • 2021-01-19
      • 2013-01-13
      • 2017-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多