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

Form: get data

parent 472e147c
No related branches found
No related tags found
No related merge requests found
......@@ -9,10 +9,20 @@ class Field {
}
public function html() {
// Todo, if isset($_POST[$this->name]) && !$this->validate() => Show a error msg explanation for this line.
return '<div class="form-group">
<label for="form'.$this->name.'">'.ucfirst($this->name).'</label>
<input type="text" class="form-control" name="'.$this->name.'" value="'.$this->value.'" >
</div>';
}
/*
Load the data from $_POST
and return false, if data is not valid !
*/
public function validate() {
$this->value = $_POST[$this->name];
return true;
}
}
\ No newline at end of file
......@@ -19,6 +19,10 @@ class Form {
if(isset($_POST["submitForm"])) {
$post = true;
// Apply validators
$success = true;
foreach($this->fields as $field) {
$success = $success && $field->validate();
}
// If all validators ok, commit
} else {
......
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