diff --git a/class/genderfield.php b/class/genderfield.php new file mode 100644 index 0000000000000000000000000000000000000000..d09f34aad240f725423e351f8f17bd6b2aea7727 --- /dev/null +++ b/class/genderfield.php @@ -0,0 +1,31 @@ +<?php + +class GenderField extends Field +{ + public function html() { + // Todo, if isset($_POST[$this->name]) && !$this->validate() => Show a error msg explanation for this line. + $html = '<div class="form-group"> + <label for="form'.$this->name.'">'.$this->label.'</label> + <select class="form-control" name="'.$this->name.'">';' + <option value="M" selected>Male</option> + <option value="F">Femelle</option> + </select> + </div>'; + return $html; +} + + public function validate() + { + $this->value = $_POST[$this->name]; + return true; + } + + public function show() { + if ($this->value == 'M') { + $html = 'Male'; + } else { + $html = 'Femelle'; + } + return $html; + } +}