function __construct($table, $id = 0) { $fields = $id == 0 ? aimsys::_getinsertfields($table) : aimsys::_getupdatefields($table); $this->_elms = (object) array(); $ii = 0; foreach ($fields as $f) { $pri = aimsys::_getprimary($table); if ($id > 0) { $select = "SELECT * FROM `{$table}` WHERE `{$pri}` = {$id}"; $result = new db($select); $row = $result[0]; } $p = new params($table, $f); // Setup the parameters for the input field. params('table','col') $p->input_value = $row[$f]; // Set the value of the field, if edit. $p->update_allowed = $id == 0 ? 'true' : $p->update_allowed; $parent = $p->input_type; // Mine the type of input from the param set $i = new $parent($p); // Create new instance of input type $this->_elms->{$ii}->label = $i->_label->get(); // Get the label $this->_elms->{$ii}->input = $i->get(); // Get the element $this->_elms->{$ii}->params = $i; // Get the element params $ii++; } $p = new params(); $p->input_name = 'frm_name'; $p->input_type = 'hidden'; $p->input_value = $this->name; $i = new hidden($p); $this->_elms->{$ii}->input = $i->get(); // Get the element $this->_elms->{$ii}->params = $i; // Get the element params $ii++; $p = new params(); $p->input_name = 'table_name'; $p->input_type = 'hidden'; $p->input_value = $table; $i = new hidden($p); $this->_elms->{$ii}->input = $i->get(); // Get the element $this->_elms->{$ii}->params = $i; // Get the element params $ii++; }