ich hab ein kleines Problem
ich hab eine Form Klasse wo spezielle Inputs etc generiert werden, dazu gibts die Funktion auch Select-Felder hinzuzufügen. Das ganz sieht so aus:
Code: Alles auswählen
$form = new form(...);
$form->addSelect('selectname');
$form->addSelect->add('name', 'value');
$form->addSelect->add('name', 'value');
$form->addSelect->add('name', 'value');
$form->addSelect->out();
Code: Alles auswählen
class form{
var $ausgabe = array();
var $addSelect;
/* .... */
function addSelect($name, $selected = '', $attributes = array()) {
$selected = ($this->get($selected)) ? $this->get($selected) : $selected;
$this->addSelect = new SelectField($name, $selected, $this->temp_head, $attributes);
}
/* .... */
}
class SelectField extends form {
var $chache = array(); #Zwischenspeichern
function add($name, $value, $attributes = array()) {
if($name == $this->selected && $this->selected != false) $attributes['selected'] = 'selected';
$this->chache[]= $this->add_field($name, $value, 'option', $attributes); #add_field kommt von form
}
function out() {
global $form;
$return = '';
foreach($this->chache as $val) {
$return .= $val;
}
$form->ausgabe[] = '<div class="form_list>
'.$this->temp_head.'
<select name="'.$this->name.'" '.$attributes.'>
'.$return.'
</select>
</div>';
$this->temp_head = '';
}
}
Optimierung: Kann man auch irgendwie das $form->addSelect->out(); weglassen? sodass er das am Ende autoamtisch in die Variable speichert?
Würd mich tierisch über Antworten freuen
Gruß Meusi