Codeigniter - 使用set_value()填充表单进行编辑(不涉及POST) [英] Codeigniter - using set_value() to populate a form for editing (with no POST involved)

查看:207
本文介绍了Codeigniter - 使用set_value()填充表单进行编辑(不涉及POST)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含表单的视图。与输入字段和单选按钮。此表单需要填充数据库中的数据,以便将其用作数据编辑表单。

I have a view containing a form. with input fields and radio buttons. This form needs to be populated with the data from database, so as to use it as an data editing form.

我已使用set_value()函数进行表单验证其中视图从post后的相同控制器调用。 但是如何使用set_value函数与POST?即只需填充加载的视图中的窗体中的值

I have used the set_value() function for the form validation where the view is called from the same controller after the post. But how to use set_value function with out a POST? i.e. simply populate the values in a form in the view that's loaded. with say, an Array or object from database.

推荐答案

您可以像这样使用

set_value('myfield', isset($databaseData['myfield']) ? $databaseData['myfield'] : '');

$ databaseData 您已在控制器中加载并传递给视图的数据库

$databaseData will contain the data from the database which you have loaded in the controller and passed to view

$data['databaseData']= $this->my_model->find($parameters);

$this->load->view('myformview',$data);

这篇关于Codeigniter - 使用set_value()填充表单进行编辑(不涉及POST)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆