0

Codeigniter は、フォームが投稿されるたびに白い画面を表示します:

コントローラーのロジックは次のとおりです [controllers/account.php]:

class Account extends CI_Controller
{
   public function create()
   {
    if($this->input->post(NULL, TRUE)){
        $params = $this->input->post();
        //add validation layer
        $accountOptions = array($params are used here)
        $this->load->model('account/account', 'account');
        $this->account->initialize($accountOptions);
        $this->account->save();
    }
            $header['title'] = "Create Free Account";
    $this->load->view('front_end/header', $header);
    $this->load->view('main_content');
    $content['account_form'] = $this->load->view('forms/account_form', NULL, TRUE);
    $this->load->view('account/create', $content);
    $footer['extraJs'] = "account";
    $this->load->view('front_end/footer', $footer);
        }
 }

アカウント モデルのロジック [models/account/account.php] は次のとおりです。

 class Account extends CI_Model 
 {

    public function __construct()
{
    parent::__construct();
}

public function initialize($options)
{
      //initialize
    }
 }

ビューは最初に正常に読み込まれ、次にフォームに入力して送信をクリックすると、白いページだけが読み込まれます。コントローラーに __construct を追加して、そこからアカウント/アカウントを読み込もうとしましたが、フォームは読み込まれません。何か案は?

問題が見つかりました:
- モデル アカウントの定義が重複しており、error_reporting がオフになっていました。

4

2 に答える 2

0

Account同じ名前(コントローラーとモデル)を持つ 2 つのクラスを持つべきではありません。サーバーおよび/またはCodeigniterログを確認して、そこに表示されるはずです。

コントローラー クラス Account とモデル クラス M_Account を呼び出すことをお勧めします。その後、モデルをロードするたびに、モデルの名前を account に変更できます。

$this->load->model('account/m_account', 'account');
于 2013-10-11T04:09:50.983 に答える
0
public function __construct()
{
    parent::__construct();
$this->load->model("account/account");
}
you load model,library and helper files in construct dont load to inside a function
于 2013-10-11T05:00:56.710 に答える