Well the task was type of data should be shown in HTML types, textfields, calendars and so on.
What i created is a FieldType factory which could load a special childclass if it is defined and would otherwise use the standard data class to handle it, this makes it possible to have a standard behavior for new data which might approach later and you don´t have to create a new class at once. Only if a special behavior is wanted you need to create a sub class for your field type.
I used some kind of Factory::Pattern to load the class which is returning the standard class if a child class for the field type is not existing, usually i hate classes or function being called by dynamic names but in this case it is very useful doesn´t mean a security risk cause the class has to be loaded in your php code before and will not bee included by thinks like
include "$classname".php or something
class Field_standard
{public
$value=
"";
... other functions ...
public
function getHtmlForm
(){ return '<input type="text" name="'.
$this->
strName.
'" value="'.
$this->
getValue().
'" />';
}}class Field_text Extends Field_standard
{ public
function getHtmlForm
(){ return '<textarea name="'.
$this->
strName.
'">'.
$this->
getValue().
'</textarea>';
}}class FieldFactory
{ static public
function create
($strFieldName,
$strFieldType) { $classname=
"Field_$strType";
if (class_exists($classname,
false)) { return new $classname($strFieldName,
$strFieldType);
}else{ return new CellField_standard
($strFieldName,
$strFieldType,
$strDefaultValue,
$strDescription,
$boolEditable);
} }}//class