mirror of
https://github.com/bcit-ci/CodeIgniter.git
synced 2025-02-20 11:13:29 +08:00
...
parent
2e82b6b0e2
commit
29ba2a7877
@ -1,5 +1,7 @@
|
||||
This depends on [[XAJAX]] CI library. If you don't want to use that then it should be simple to eliminate this dependency.
|
||||
|
||||
This code is released under the same license under which CI is released.
|
||||
|
||||
How to use this code:
|
||||
|
||||
1)Copy the functions below into your controller,
|
||||
@ -13,6 +15,11 @@ Here are the functions required:
|
||||
The _manageFields function is an internal function called using xajax:
|
||||
|
||||
[code]
|
||||
/**
|
||||
* @author Bob Beauchamp
|
||||
* @link http://www.codeigniter.com/wiki/Generate_a_form_from_a_DB_table/
|
||||
*/
|
||||
|
||||
function _manageFields($table){
|
||||
$table = $this->input->xss_clean($table);
|
||||
$fields = $this->db->list_fields($table);
|
||||
@ -41,6 +48,11 @@ function _manageFields($table){
|
||||
The _addTabletoManagementTable function in an internal function called using xajax:
|
||||
|
||||
[code]
|
||||
/**
|
||||
* @author Bob Beauchamp
|
||||
* @link http://www.codeigniter.com/wiki/Generate_a_form_from_a_DB_table/
|
||||
*/
|
||||
|
||||
function _addTableToManagementTable($table){
|
||||
$table = $this->input->xss_clean($table);
|
||||
$tableQuery = $this->db->getWhere('Management_tables',array('TableName' => $table));
|
||||
@ -66,6 +78,11 @@ function _addTableToManagementTable($table){
|
||||
Simple xajax toggle for table management
|
||||
|
||||
[code]
|
||||
/**
|
||||
* @author Bob Beauchamp
|
||||
* @link http://www.codeigniter.com/wiki/Generate_a_form_from_a_DB_table/
|
||||
*/
|
||||
|
||||
function _toggleManagement($table,$field = FALSE){
|
||||
$objResponse = new xajaxResponse();
|
||||
if(!$field){
|
||||
@ -113,6 +130,11 @@ function _toggleManagement($table,$field = FALSE){
|
||||
This is the function you want to reference from your browser in order to start the magic rolling.
|
||||
|
||||
[code]
|
||||
/**
|
||||
* @author Bob Beauchamp
|
||||
* @link http://www.codeigniter.com/wiki/Generate_a_form_from_a_DB_table/
|
||||
*/
|
||||
|
||||
function managetables(){
|
||||
$this->load->library('xajax');
|
||||
$this->xajax->registerFunction(array('toggleManagement',&$this,'_toggleManagement'));
|
||||
@ -157,6 +179,11 @@ function managetables(){
|
||||
I have made this an internal function so I can just call it from other functions and have it return the basic form elements. Can work as a url-addressable function with some minor tweaks. This function depends on the table being passed into to already being in the management tables (see SQL code below). I have debated making it automatically suck the table and fields into the management tables but have not yet taken that step since I like to be a bit more hands-on with this kind of thing.
|
||||
|
||||
[code]
|
||||
/**
|
||||
* @author Bob Beauchamp
|
||||
* @link http://www.codeigniter.com/wiki/Generate_a_form_from_a_DB_table/
|
||||
*/
|
||||
|
||||
function _formBuilder($table,$values=array(),$valuesAsHidden=FALSE){
|
||||
$columns = $this->db->query($this->db->_list_columns($table));
|
||||
if($columns->num_rows() > 0){
|
||||
|
Loading…
x
Reference in New Issue
Block a user