codeigniter如何访问config/form_validation.php数据?
我在我的codeigniter如何访问config/form_validation.php数据?,php,codeigniter,Php,Codeigniter,我在我的config/form\u validation.php和我的controller中复制了数据。 来自表单验证的字段和标签与我在控制器中为id、名称和占位符指定的相同 我是否必须将该数据提取到第三个位置,并在这两个位置中引用它 application/config/form_validation.php $config = array( 'register' => array(
config/form\u validation.php
和我的controller
中复制了数据。
来自表单验证的字段和标签与我在控制器中为id、名称和占位符指定的相同
我是否必须将该数据提取到第三个位置,并在这两个位置中引用它
application/config/form_validation.php
$config = array(
'register' => array(
array(
'field' => 'register_username',
'label' => 'Username',
'rules' => 'trim|required|exact_length[5]'
),
.....
$this->viewdata['register_username'] = array(
'id' => 'register_username',
'name' => 'register_username',
'type' => 'text',
'placeholder' => 'Username'
);
...
application/controllers/mycontroller.php
$config = array(
'register' => array(
array(
'field' => 'register_username',
'label' => 'Username',
'rules' => 'trim|required|exact_length[5]'
),
.....
$this->viewdata['register_username'] = array(
'id' => 'register_username',
'name' => 'register_username',
'type' => 'text',
'placeholder' => 'Username'
);
...
我不知道你为什么要在控制器中复制数据。你可能会发现它更容易使用
这将从整体上清理您的模型/应用程序结构。模型扩展库本身允许CRUD方法的自动化