Exemplo n.º 1
0
 $user = NULL;
 $s_submit = "button.new_customer";
 if ($userid !== NULL) {
     try {
         $user = db_Customer::load($dbh, $userid);
     } catch (PDOException $e) {
         print "Database error: " . htmlspecialchars($e->getMessage());
         die;
     }
     $s_submit = "button.update_customer";
 }
 if ($user === NULL) {
     $user = new db_Customer();
 }
 $s_submit = htmlspecialchars(getlocalstr($s_submit));
 $user_data = $user->to_array();
 echo "   <h1>{$title}</h1>\n";
 echo "   <form method=\"post\" enctype=\"application/x-www-form-urlencoded\" action=\"edit.php\" name=\"editform\">\n    <table class=\"formtable\">\n";
 foreach ($formfields as $field) {
     if (!$is_submit && array_key_exists($field->Name, $user_data)) {
         $field->Value = $user_data[$field->Name];
     }
     $labelclass = 'formlabel';
     if (!$field->IsValid() && $is_submit) {
         $labelclass = 'formerror';
     }
     echo "    <tr>\n";
     if ($field->InputType == 'checkbox' || $field->InputType == 'radio') {
         echo "     <td class=\"formcheckbox\">" . $field->getInputElement() . "</td>\n";
         echo "     <td class=\"{$labelclass}\">" . $field->getLabelElement() . "</td>\n";
     } else {