Vérification erreur de saisie nom gallerie WIP

This commit is contained in:
Fred Tempez 2020-03-27 18:58:47 +01:00
parent 9d059aa01b
commit 5d8ad82ad6
3 changed files with 7 additions and 8 deletions

View File

@ -474,7 +474,7 @@ class common {
// La clef est une chaine // La clef est une chaine
else { else {
foreach($this->input as $type => $values) { foreach($this->input as $type => $values) {
// Champ obligatoire // Champ obligatoire
if($required) { if($required) {
$this->addRequiredInputNotices($key); $this->addRequiredInputNotices($key);
} }

View File

@ -125,11 +125,12 @@ class gallery extends common {
public function add() { public function add() {
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if($this->isPost()) {
$success = false;
if (!empty($this->getInput('galleryAddName')) ) { if (!empty($this->getInput('galleryAddName')) ) {
$galleryId = helper::increment($this->getInput('galleryAddName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0)])); $galleryId = helper::increment($this->getInput('galleryAddName', helper::FILTER_ID, true), (array) $this->getData(['module', $this->getUrl(0)]));
$this->setData(['module', $this->getUrl(0), $galleryId, [ $this->setData(['module', $this->getUrl(0), $galleryId, [
'config' => [ 'config' => [
'name' => $this->getInput('galleryAddName',helper::FILTER_STRING_SHORT,true), 'name' => $this->getInput('galleryAddName',helper::FILTER_STRING_SHORT, true),
'directory' => $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true), 'directory' => $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true),
'sort' => $this->getInput('galleryAddSort'), 'sort' => $this->getInput('galleryAddSort'),
'order' => count($this->getData(['module',$this->getUrl(0)])) + 1 'order' => count($this->getData(['module',$this->getUrl(0)])) + 1
@ -137,14 +138,12 @@ class gallery extends common {
'legend' => [] 'legend' => []
]]); ]]);
$success = true; $success = true;
} else {
$success = false;
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => $success === true ? helper::baseUrl() . $this->getUrl() . '/config' : helper::baseUrl() . $this->getUrl() . '/add', 'redirect' => $success ? helper::baseUrl() . $this->getUrl(0) . '/config' : helper::baseUrl() . $this->getUrl(0) . '/add',
'notification' => $success === true ? 'Modifications enregistrées' : 'Le nom de la galerie est obligatoire', 'notification' => $success ? 'Modifications enregistrées' : 'Le nom de la galerie est obligatoire',
'state' => $success 'state' => $success
]); ]);
} else { } else {
// valeurs en sortie // valeurs en sortie

View File

@ -20,7 +20,7 @@
<div class="row"> <div class="row">
<div class="col4"> <div class="col4">
<?php echo template::text('galleryAddName', [ <?php echo template::text('galleryAddName', [
'label' => 'Nom' 'label' => 'Nom de la galerie'
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">