Generating forms using OOP

From: Date: Fri, 06 Dec 2002 23:43:47 +0000
Subject: Generating forms using OOP
Groups: php.general php.windows 
Request: Send a blank email to php-general+get-127343@lists.php.net to get a copy of this message
Hi People, I ve just started with some OOP programming in PHP and now i have to build a set of classes that can generate a html form.. But i have a problem with the <select><option></option></select> thing.... I hope someone can help me here or give me some pointers,... any help is apreciated. Here is a part of my code : class selectField extends formElement { //Constructor function selectField($name, $value) {
       formElement::setName($name);
       formElement::setValue($value);
} function generateSelectField() {
       $theOutput = "<select name=\"".$this->name."\">\n";
       foreach($this->value as $key=>$val) {
           $theOutput .= "<option value=\"".$this->value."\">".$this->value."</option>\n";
       }
       $theOutput .= "</select>\n";
       Return $theOutput;
} } This is how i call the Object: $test[] = "Test1"; $test[] = "Test2"; $test[] = "Test3"; $test[] = "Test4"; $test[] = "Test5"; $select = new selectField("testje", $test); echo$select->generateSelectField(); But all i get is a select box with the word Array in it 5 times...Thanks for your time... Best regards, Davy Obdam mailto:info@davyobdam.com

« previous php.general (#127343) next »