Skip to content
Snippets Groups Projects
Commit d0724043 authored by Matthieu Guffroy's avatar Matthieu Guffroy
Browse files

improvment

parent 0e5710e7
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,11 @@ class Employe extends Personne
protected $is_veterinaire;
public $_specialFields = array(
"is_veterinaire" => array(
"t" => "BoolField"
"t" => "BoolField",
"label" => "Veterinaire"
),
"id_national" => array(
"label" => "Identifiant national"
));
public function id_national()
......
......@@ -4,11 +4,13 @@ class Field {
protected $name;
protected $value;
protected $primary;
public $label;
public function __construct($name, &$value, $primary=false) {
$this->name = $name;
$this->value =& $value;
$this->primary = $primary;
$this->label = ucfirst($name);
}
public function html($form) {
......@@ -44,7 +46,7 @@ class Field {
}
public function getLabel() {
return ucfirst($this->name);
return $this->label;
}
}
......@@ -52,13 +52,18 @@ class Objet
{
$ret = array();
foreach(array_keys(get_object_vars($this)) as $keyName) {
$field = null;
if($keyName[0] == "_") { continue; }
if($keyName == $this->_primaryAttr && $this->_primaryAttr == "id") { $ret[] = new Field($keyName, $this->$keyName, true); continue; }
if(in_array($keyName, array_keys($this->_specialFields))) {
$ret[] = new $this->_specialFields[$keyName]["t"]($keyName, $this->$keyName);
if(isset($this->_specialFields[$keyName]["t"])) {
$field = new $this->_specialFields[$keyName]["t"]($keyName, $this->$keyName);
} else {
$ret[] = new Field($keyName, $this->$keyName);
$field = new Field($keyName, $this->$keyName);
}
if(isset($this->_specialFields[$keyName]["label"])) {
$field->label = $this->_specialFields[$keyName]["label"];
}
$ret[] = $field;
}
return $ret;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment