私は現在 CodeIgniter を学習しており、小さなプロジェクトで使用しています。ビューのコードを繰り返し記述する必要がないように、テンプレートを作成したいと思います。この投稿での jruzafa の回答が気に入っています: How to Deal With Codeigniter Templates?
コントローラーで:
//Charge the view inside array
$data['body'] = $this->load->view('pages/contact', '', true);
//charge the view "contact" in the other view template
$this->load->view('template', $data);
ビュー template.php で:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es">
<head>
<title>Template codeigniter</title>
</head>
<body>
<div>
<?=$body?>
</div>
<div class="clear"></div>
<div>Footer</div>
</div>
</body>
</html>
$body はビュー コンタクトです。
しかし今、私は問題に直面しています。form_view を文字列として $data['body'] に渡すと、フォームの検証が機能しません。それを回避する方法はありますか?
ありがとう。