[eluser]Unknown[/eluser]
I am a beginner at this - and don't quite get it.
I am almost using "generate a form from a db table" which says I can use the formbuilder function by itself. I can't seem to get it to work though.
Using the example given I have in controller/managetables.php
Code:
<?php
Class Managetables Extends Controller
{
function index()
{
$template['xajax_js'] = $this->xajax->getjavascript(null, 'http://localhost/custom/javascript/xajax.js');
$attributes = array('name' => 'sectionContentForm',
'id' => 'sectionContentForm',
'onSubmit' => 'xajax_addUser(xajax.getFormValues(\'sectionContentForm\'));return false;');
$formOutput = form_open('#',$attributes);
$formElements = $this->_formBuilder('users');
foreach($formElements as $name => $htmlTag){
$formOutput .= '<label for="'.$name.'">';
if(stristr($htmlTag,'type="hidden"')){
$formOutput .= $this->$name.'</label><br />'.$htmlTag;
$displayName = str_replace('<input type="hidden" name="'.$name.'" value="','',$htmlTag);
$displayName = str_replace('" />','',$displayName);
$formOutput .= '<b> -- '.$displayName.'</b><br />';
} else {
$formOutput .= $this->$name.'</label><br />'.$htmlTag.'<br />';
}
}
$formOutput .= form_submit('submitContentForm','Create').form_close();
$template['formOutput'] = $formOutput;
$this->load->view('managetables', $template);
}
function Managetables(){
parent::controller();
$this->load->library('xajax');
$this->load->helper('url');
$this->load->helper('form');
$this->load->helper('html');
$this->xajax->registerFunction(array('toggleManagement',&$this,'_toggleManagement'));
lots more here ...
}
function _formBuilder($table,$values=array(),$valuesAsHidden=FALSE){
$columns = $this->db->query($this->db->_list_columns($table));
if($columns->num_rows() > 0){
foreach ($columns->result_array() as $columnInfo){
foreach($columnInfo as $key => $val){
if($key == 'Field'){
$fieldName = $val;
// if(!$this->data->getManagementStatus($table,$fieldName)) break; //comment this out if you are using only this function and not the supporting "management" fuctions
}
$arrTableInfo[$fieldName][$key] = $val;
}
}
$formDisplay = '';
lots more here ...
}
and in views/managetables.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php echo $xajax_js;?>
</head>
<body>
<?php echo $formOutput ;?>
</body>
</html>
I get an error message at the top for every field in the
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Managetables::$id
Filename: controllers/managetables.php
Line Number: 22
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Managetables::$last_name
Filename: controllers/managetables.php
Line Number: 22
and then I also get the form, but only the input line - no label?
anyhelp?
thanks
Katherine