我目前正在学习CodeIgniter并将其用于一个小型项目。我想制作一个模板,以便我不需要为视图编写重复的代码。我喜欢jruzafa在这个帖子答案:How to Deal With Codeigniter Templates?将视图作为字符串传递时,codeIgniter表单验证不起作用
在控制器:
//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>
$身体是查看联系人。
但现在我面临一个问题。如果我将form_view作为字符串传递给$ data ['body'],表单验证不起作用。有什么办法可以解决它吗?
谢谢。
你能后的验证设置和接触的视图页。我正在研究一个具有如此初始化的边栏的项目,这些错误工作正常。 –