id; switch ($this->type) { case self::TYPE_TEXT: $el = new Monkeys_Form_Element_Text($varname); break; case self::TYPE_DATE: $el = new Monkeys_Form_Element_Date($varname); $el->addValidator('date', false, array('format_type' => 'Y-m-d')) ->setShowEmptyValues(true) ->setStartEndYear(1900, date('Y') - 7) ->setReverseYears(true); break; case self::TYPE_GENDER: translate('Male'); translate('Female'); $el = new Monkeys_Form_Element_Radio($varname); $el->setSeparator('  ') ->addMultiOption('M', 'Male') ->addMultiOption('F', 'Female'); break; case self::TYPE_COUNTRY: $el = new Monkeys_Form_Element_Country($varname); break; case self::TYPE_LANGUAGE: $el = new Monkeys_Form_Element_Language($varname); break; case self::TYPE_TIMEZONE: $el = new Monkeys_Form_Element_Timezone($varname); break; case self::TYPE_EMAIL: $el = new Monkeys_Form_Element_Text($varname); $el->addValidator('EmailAddress'); break; default: throw new Exception('Unknown field type: ' . $this->type); break; } $el->setLabel($this->name); $el->setValue($this->value); return $el; } }