Napisałem prostą klasę (do generowania formularzy), aby od czegoś zacząć:
class formClass { public $output; public $startedGroup; public function formGroup(){ if($startedGroup){ $this -> output .= "</div>\n"; } $this -> output .= "<div>\n"; $this -> startedGroup = true; } public function formElement($name){ $this -> output .= "<div>".$name.": <input type='text' name='".$name."' /></div>\n"; } public function printForm(){ $this -> output .= "</div>\n"; } } $form = new formClass; $form -> formGroup(); $form -> formElement('imie'); $form -> formElement('nazwisko'); $form -> formElement('wiek'); $form -> formGroup(); $form -> formElement('adres_email'); $form -> formElement('telefon'); $form -> printForm();
I teraz problem... wszędzie pisze się aby nie mieszać logiki z HTMLem, a ja tu nie widzę żadnej możliwości, aby wywoływane metody nie zwracały HTMLa...
W jaki sposób powinno się prawidłowo coś takiego robić?