diff --git a/class/field.php b/class/field.php index ef44b2e5559ddc83893d385a93929dc647dcca34..63c6efa12dbf1e6d68d163df594e0844bec95344 100644 --- a/class/field.php +++ b/class/field.php @@ -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.'" > + <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 diff --git a/class/form.php b/class/form.php index c4061f6448b3f864bbd2ca1e469aa9ab70f41cfe..4baf18ade945e18723e202de8aee326bdcac287f 100644 --- a/class/form.php +++ b/class/form.php @@ -19,8 +19,19 @@ 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 + if($success) { + if($this->action == "Modifier") { + $this->object->update(); + } else { + $this->object->insert(); + } + } } else { $post = false; } @@ -38,4 +49,8 @@ class Form { return $this->fields; } + public function getAlerts() { + return '<p class="bg-danger">Code en cours d\'implémentation, l\'enregistrement n\'a pas été ajouté !</p>'; + } + } \ No newline at end of file diff --git a/class/objet.php b/class/objet.php index 6de081941456a3e259fa44dc3dba751112328938..6f993f4c3a9ead4e3348f80e3912466638574855 100644 --- a/class/objet.php +++ b/class/objet.php @@ -51,7 +51,7 @@ class Objet return $ret; } - public static function insertAll() + public static function insert() { $className = get_called_class(); $dbName = lcfirst($className); diff --git a/css/custom_boostrap.css b/css/custom_boostrap.css new file mode 100644 index 0000000000000000000000000000000000000000..68c51a5b54f1b05520ffd98737a2e689f3860ae7 --- /dev/null +++ b/css/custom_boostrap.css @@ -0,0 +1,20 @@ +#footer { + position: absolute; + bottom: 0; + width: 100%; + /* Set the fixed height of the footer here */ + height: 30px; + background-color: #f5f5f5; +} + +.footer_container { + width: auto; + max-width: 680px; + padding-top: 10px; + padding-bottom: 0px; + text-align : center; +} + +.text-footer { + +} \ No newline at end of file diff --git a/view/form.php b/view/form.php index defe74bbebd003d5737a7a5e5b6dc2e98c6611c8..2d0fc365e49b79d443efdf7bea706c88cc4d99a7 100644 --- a/view/form.php +++ b/view/form.php @@ -3,6 +3,7 @@ <div class="page-header"> <h1><?php echo $formConf->getTitle(); ?></h1> </div> + <?php echo $formConf->getAlerts(); ?> <form role="form" method="post"> <input type="hidden" name="submitForm" value="1"> <?php foreach($formConf->getFields() as $field): ?>