Skip to content
Snippets Groups Projects
Commit 4fa3c319 authored by clement's avatar clement
Browse files

Merge branch 'master' of gitlab.utc.fr:nf17-camp-p14/clivi

parents 30c31f40 7cad9691
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.'" >
<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,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
......@@ -51,7 +51,7 @@ class Objet
return $ret;
}
public static function insertAll()
public static function insert()
{
$className = get_called_class();
$dbName = lcfirst($className);
......
#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
......@@ -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): ?>
......
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