Date: 12/14/00
- Next message: Brian Sumpter: "[phplib] Netscape 4.7 & 4.75 problems....."
- Previous message: Martin Larsen: "[phplib] IntegratedTemplate and case-sensitivity"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I've found some troubles trying to set all the fields of a form (derived
from tpl_form) to some default values.
It's easy to setup a "add-new" form and insert all the values to the
database.
What i'm trying to do now is a simple edit-and-update form using the same
tpl_form class, loading the old values and updating the modified ones.
So i select those values from the database, populate an array, and call to
set_default_values function.
But if i don't include a field in the array with the "form_name" key and
his value, nothing happens.ç
>From the tpl_form class i understand that the "form_name" is included
always as a hidden field, and so always available.
Does anybody know why at some point the field form_name becomes empty?
Is there a better way to populate the values to the form and then, once
modified, update the database?
If some of you have a different implementation to share it will be welcome.
Thanks in advance.
Here some pseudocode:
require("myderivedform.inc");
$action=$HTTP_GET_VARS["action"];
$db = new DB_Example;
$f = new myderivedform;
$f->init(array());
if ($action=="edit") {
#query_the database
$ary=array();
#populate the array $ary from the result set
$ary["form_name"]="myderivedform"; // here the trick... or is it
necessary?
$f->set_default_values($ary);
}
if ($fv = $f->get_values()) {
if ($action=="edit")
//$query= update query
else
//$query= insert query
$db->query($query);
//error check
}else{
$f->display();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>
- Next message: Brian Sumpter: "[phplib] Netscape 4.7 & 4.75 problems....."
- Previous message: Martin Larsen: "[phplib] IntegratedTemplate and case-sensitivity"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

