我使用CodeIgniter 4并以以下方式加载表单助手,但它仍然显示,
调用未定义的函数form_open((
在BaseController.php中,我正在自动加载表单帮助程序。
protected $helpers = ["form"];
路线:
$routes->get('admin/login', 'adminLoginController::index');
控制器:
public function index()
{
echo view('admin/login');
}
视图:
<?php echo form_open('admin/dologin');?>
<?= csrf_token() ?>
<div class="input-group mb-3">
<input type="email" class="form-control" name="email" placeholder="Email">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-envelope"></span>
</div>
</div>
</div>
<div class="input-group mb-3">
<input type="password" class="form-control" name="password" placeholder="Password">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-lock"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-4">
<button type="submit" class="btn btn-primary btn-block">Sign In</button>
</div>
<!-- /.col -->
</div>
<?php echo form_close();?>
我如何摆脱这个错误
Call to undefined function form_open()
加载此Helper
<blockquote\使用以下代码加载此帮助程序:
<?php
helper('form');
>在您的app/Controllers/BaseController.php
文件中,
<?php
namespace AppControllers;
// ...
class BaseController extends Controller
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
// Do Not Edit This Line
parent::initController($request, $response, $logger);
// Preload any models, libraries, etc, here.
helper("form");
}
}