Add re-populate form on submission error
This commit is contained in:
parent
d52db2e1d2
commit
7277f1e98d
|
@ -121,7 +121,7 @@ namespace controllers\publics;
|
|||
|
||||
if (!$this->internal_webhook->create($_SESSION['user']['id'], $url, $type))
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce webhook.');
|
||||
\FlashMessage\FlashMessage::push('danger', 'Impossible de créer ce webhook, vérifiez qu\'il s\'agit bien d\'une URL HTTP(S) valide.');
|
||||
|
||||
return $this->redirect(\descartes\Router::url('Webhook', 'add'));
|
||||
}
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
$_SESSION['csrf'] = str_shuffle(uniqid().uniqid());
|
||||
}
|
||||
|
||||
//Save previous $_POST for re-populate forms on validation errors
|
||||
$_SESSION['previous_http_post'] = $_SESSION['http_post'] ?? [];
|
||||
$_SESSION['http_post'] = $_POST;
|
||||
|
||||
//Routing current query
|
||||
try
|
||||
{
|
||||
|
|
|
@ -41,21 +41,21 @@
|
|||
<div class="form-group">
|
||||
<label>Nom commande</label>
|
||||
<div class="form-group">
|
||||
<input name="name" class="form-control" type="text" placeholder="Nom commande" autofocus required>
|
||||
<input name="name" class="form-control" type="text" placeholder="Nom commande" autofocus required value="<?php $this->s($_SESSION['previous_http_post']['name'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Commande à appeler (la commande sera appelée depuis le dossier "<?php echo PWD_SCRIPTS; ?>")</label>
|
||||
<div class="form-group input-group">
|
||||
<span class="input-group-addon"><span class="fa fa-link"></span></span>
|
||||
<input name="script" class="form-control" type="text" placeholder="Ex : chauffage/monter.sh" autofocus required>
|
||||
<input name="script" class="form-control" type="text" placeholder="Ex : chauffage/monter.sh" autofocus required value="<?php $this->s($_SESSION['previous_http_post']['script'] ?? ''); ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Niveau administrateur obligatoire</label>
|
||||
<div class="form-group">
|
||||
<input name="admin" type="radio" value="1" required /> Oui
|
||||
<input name="admin" type="radio" value="0" required /> Non
|
||||
<input name="admin" type="radio" value="1" required <?= (isset($_SESSION['previous_http_post']['admin']) && (bool) $_SESSION['previous_http_post']['admin']) ? 'checked' : ''; ?>/> Oui
|
||||
<input name="admin" type="radio" value="0" required <?= (isset($_SESSION['previous_http_post']['admin']) && !(bool) $_SESSION['previous_http_post']['admin']) ? '' : 'checked'; ?>/> Non
|
||||
</div>
|
||||
</div>
|
||||
<a class="btn btn-danger" href="<?php echo \descartes\Router::url('Command', 'list'); ?>">Annuler</a>
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<label>Nom du groupe conditionnel</label>
|
||||
<div class="form-group input-group">
|
||||
<span class="input-group-addon"><span class="fa fa-users"></span></span>
|
||||
<input name="name" class="form-control" type="text" placeholder="Nom groupe" autofocus required>
|
||||
<input name="name" class="form-control" type="text" placeholder="Nom groupe" autofocus required value="<?php $this->s($_SESSION['previous_http_post']['name'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@ -51,7 +51,7 @@
|
|||
Les conditions vous permettent de définir dynamiquement les contacts qui appartiennent au groupe en utilisant leurs données additionnelles. Pour plus d'informations consultez la documentation relative à <a href="#">l'utilisation des groupes conditionnels.</a><br/>
|
||||
Vous pouvez prévisualiser les contacts qui feront parti du groupe en cliquant sur le bouton <b>"Prévisualiser les contacts"</b>.
|
||||
</p>
|
||||
<input class="form-control" name="condition" placeholder="Ex : contact.datas.gender == 'male'"/>
|
||||
<input class="form-control" name="condition" placeholder="Ex : contact.gender == 'male'" value="<?php $this->s($_SESSION['previous_http_post']['condition'] ?? '') ?>"/>
|
||||
<div class="scheduled-preview-container">
|
||||
<a class="btn btn-info preview-button" href="#">Prévisualiser les contacts</a>
|
||||
</div>
|
||||
|
|
|
@ -42,15 +42,15 @@
|
|||
<label>Nom contact</label>
|
||||
<div class="form-group input-group">
|
||||
<span class="input-group-addon"><span class="fa fa-user"></span></span>
|
||||
<input name="name" class="form-control" type="text" placeholder="Nom contact" autofocus required>
|
||||
<input name="name" class="form-control" type="text" placeholder="Nom contact" autofocus required value="<?php $this->s($_SESSION['previous_http_post']['name'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Numéro de téléphone du contact</label>
|
||||
<div class="form-group">
|
||||
<input name="" class="form-control" type="tel" id="phone-international-input">
|
||||
<input name="" class="form-control" type="tel" id="phone-international-input" value="<?php $this->s($_SESSION['previous_http_post']['number'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Données du contact</label>
|
||||
<p class="italic small help" id="description-datas">
|
||||
|
@ -58,6 +58,16 @@
|
|||
Laissez vide si vous ne souhaitez pas renseigner d'informations supplémentaires pour le contact. Utilisez uniquement des lettres, des chiffres et des underscore pour les noms de données, ni espace ni caractères spéciaux.
|
||||
</p>
|
||||
<div class="contact-datas-container">
|
||||
<?php foreach ($_SESSION['previous_http_post']['datas'] ?? [] as $key => $value) { ?>
|
||||
<?php if ($value == null) { continue; } ?>
|
||||
<div class="form-group">
|
||||
<input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*" value="<?php $this->s($key) ?>">
|
||||
:
|
||||
<input name="" class="form-control contact-data-value" type="text" placeholder="Valeur de la donnée" value="<?php $this->s($value) ?>">
|
||||
<a href="#" class="contact-datas-remove"><span class="fa fa-times"></span></a>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
<div class="form-group">
|
||||
<input name="" class="form-control contact-data-name" type="text" placeholder="Nom de la donnée" pattern="[a-zA-Z0-9_]*">
|
||||
:
|
||||
|
|
|
@ -42,12 +42,12 @@
|
|||
<label>Nom du groupe</label>
|
||||
<div class="form-group input-group">
|
||||
<span class="input-group-addon"><span class="fa fa-users"></span></span>
|
||||
<input name="name" class="form-control" type="text" placeholder="Nom groupe" autofocus required>
|
||||
<input name="name" class="form-control" type="text" placeholder="Nom groupe" autofocus required value="<?php $this->s($_SESSION['previous_http_post']['name'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Contacts du groupe</label>
|
||||
<input class="add-contacts form-control" name="contacts[]"/>
|
||||
<input class="add-contacts form-control" name="contacts[]" value="<?php $this->s(json_encode($_SESSION['previous_http_post']['contacts'] ?? [])); ?>"/>
|
||||
</div>
|
||||
<a class="btn btn-danger" href="<?php echo \descartes\Router::url('Group', 'list'); ?>">Annuler</a>
|
||||
<input type="submit" class="btn btn-success" value="Enregistrer le groupe" />
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
Le nom du téléphone qui enverra et recevra les messages.
|
||||
</p>
|
||||
<div class="form-group">
|
||||
<input required="required" name="name" class="form-control" placeholder="Nom du téléphone">
|
||||
<input required="required" name="name" class="form-control" placeholder="Nom du téléphone" value="<?php $this->s($_SESSION['previous_http_post']['name'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@ -58,6 +58,7 @@
|
|||
value="<?= $adapter['meta_classname'] ?>"
|
||||
data-description="<?php $this->s($adapter['meta_description']); ?>"
|
||||
data-datas-fields="<?php $this->s(json_encode($adapter['meta_datas_fields'])); ?>"
|
||||
<?= ($_SESSION['previous_http_post']['adapter'] ?? '') == $adapter['meta_classname'] ? 'selected' : '' ?>
|
||||
>
|
||||
<?php $this->s($adapter['meta_name']); ?>
|
||||
</option>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
?>
|
||||
<div id="wrapper">
|
||||
<?php
|
||||
$this->render('incs/nav', ['page' => 'phone'])
|
||||
$this->render('incs/nav', ['page' => 'phones'])
|
||||
?>
|
||||
<div id="page-wrapper">
|
||||
<div class="container-fluid">
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
Vous pouvez obtenir une prévisualisation du résultat pour un contact en cliquant sur le boutton <b>"Prévisualiser"</b>.
|
||||
</p>
|
||||
<?php } ?>
|
||||
<textarea name="text" class="form-control" required></textarea>
|
||||
<textarea name="text" class="form-control" required><?php $this->s($_SESSION['previous_http_post']['text'] ?? '') ?></textarea>
|
||||
<?php if ($_SESSION['user']['settings']['templating']) { ?>
|
||||
<div class="scheduled-preview-container">
|
||||
<label>Prévisualiser pour : </label>
|
||||
|
@ -74,7 +74,7 @@
|
|||
<?php } ?>
|
||||
<div class="form-group">
|
||||
<label>Date d'envoi du SMS</label>
|
||||
<input name="at" class="form-control form-datetime auto-width" type="text" value="<?php $this->s($now); ?>" readonly>
|
||||
<input name="at" class="form-control form-datetime auto-width" type="text" readonly value="<?php $this->s($_SESSION['previous_http_post']['at'] ?? $now) ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Numéros cibles</label>
|
||||
|
@ -88,24 +88,24 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label>Contacts cibles</label>
|
||||
<input class="add-contacts form-control" name="contacts[]" value="<?php $this->s(json_encode($prefilled_contacts)); ?>" />
|
||||
<input class="add-contacts form-control" name="contacts[]" value="<?php $this->s(json_encode($_SESSION['previous_http_post']['contacts'] ?? $prefilled_contacts)) ?>" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Groupes cibles</label>
|
||||
<input class="add-groupes form-control" name="groups[]" value="<?php $this->s(json_encode($prefilled_groups)); ?>" />
|
||||
<input class="add-groupes form-control" name="groups[]" value="<?php $this->s(json_encode($_SESSION['previous_http_post']['groups'] ?? $prefilled_groups)) ?>" />
|
||||
</div>
|
||||
<?php if ($_SESSION['user']['settings']['conditional_group'] ?? false) { ?>
|
||||
<div class="form-group">
|
||||
<label>Groupes conditionnels cibles</label>
|
||||
<input class="add-conditional-groups form-control" name="conditional_groups[]" value="<?php $this->s(json_encode($prefilled_conditional_groups)); ?>"/>
|
||||
<input class="add-conditional-groups form-control" name="conditional_groups[]" value="<?php $this->s(json_encode($_SESSION['previous_http_post']['conditional_groups'] ?? $prefilled_conditional_groups)) ?>" />
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($_SESSION['user']['settings']['sms_flash']) { ?>
|
||||
<div class="form-group">
|
||||
<label>Envoyer comme un SMS Flash : </label>
|
||||
<div class="form-group">
|
||||
<input name="flash" type="radio" value="1" required /> Oui
|
||||
<input name="flash" type="radio" value="0" required checked/> Non
|
||||
<input name="flash" type="radio" value="1" required <?= (isset($_SESSION['previous_http_post']['flash']) && (bool) $_SESSION['previous_http_post']['flash']) ? 'checked' : ''; ?>/> Oui
|
||||
<input name="flash" type="radio" value="0" required <?= (!isset($_SESSION['previous_http_post']['flash']) || (isset($_SESSION['previous_http_post']['flash']) && !(bool) $_SESSION['previous_http_post']['flash'])) ? 'checked' : ''; ?>/> Non
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
@ -115,7 +115,7 @@
|
|||
<select name="id_phone" class="form-control">
|
||||
<option value="">N'importe lequel</option>
|
||||
<?php foreach ($phones as $phone) { ?>
|
||||
<option value="<?php $this->s($phone['id']); ?>"><?php $this->s($phone['name']); ?></option>
|
||||
<option value="<?php $this->s($phone['id']); ?>" <?= ($_SESSION['previous_http_post']['id_phone'] ?? '') == $phone['id'] ? 'selected' : '' ?>><?php $this->s($phone['name']); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
@ -42,22 +42,22 @@
|
|||
<label>Adresse e-mail</label>
|
||||
<div class="form-group input-group">
|
||||
<span class="input-group-addon"><span class="fa fa-at"></span></span>
|
||||
<input name="email" class="form-control" type="email" placeholder="Adresse e-mail de l'utilisateur" autofocus required>
|
||||
<input name="email" class="form-control" type="email" placeholder="Adresse e-mail de l'utilisateur" autofocus required value="<?php $this->s($_SESSION['previous_http_post']['email'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Mot de passe (laissez vide pour générer le mot de passe automatiquement)</label>
|
||||
<div class="form-group input-group">
|
||||
<span class="input-group-addon"><span class="fa fa-lock"></span></span>
|
||||
<input name="password" class="form-control" type="password" placeholder="Mot de passe de l'utilisateur" >
|
||||
<input name="password" class="form-control" type="password" placeholder="Mot de passe de l'utilisateur">
|
||||
</div>
|
||||
</div>
|
||||
<?php if (isset($_SESSION['user']['admin']) && $_SESSION['user']['admin']) { ?>
|
||||
<div class="form-group">
|
||||
<label>Niveau administrateur : </label>
|
||||
<div class="form-group">
|
||||
<input name="admin" type="radio" value="1" required /> Oui
|
||||
<input name="admin" type="radio" value="0" required /> Non
|
||||
<input name="admin" type="radio" value="1" required <?= (isset($_SESSION['previous_http_post']['admin']) && (bool) $_SESSION['previous_http_post']['admin']) ? 'checked' : ''; ?>/> Oui
|
||||
<input name="admin" type="radio" value="0" required <?= (isset($_SESSION['previous_http_post']['admin']) && !(bool) $_SESSION['previous_http_post']['admin']) ? 'checked' : ''; ?>/> Non
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
|
|
@ -39,14 +39,14 @@
|
|||
<div class="form-group">
|
||||
<label>URL cible</label>
|
||||
<div class="form-group">
|
||||
<input name="url" class="form-control" type="text" placeholder="http://example.fr/webhook/" autofocus required>
|
||||
<input name="url" class="form-control" type="text" placeholder="http://example.fr/webhook/" autofocus required value="<?php $this->s($_SESSION['previous_http_post']['url'] ?? '') ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Type de Webhook</label>
|
||||
<select name="type" class="form-control" required>
|
||||
<option value="receive_sms">Réception d'un SMS</option>
|
||||
<option value="send_sms">Envoi d'un SMS</option>
|
||||
<option value="receive_sms" <?= ($_SESSION['previous_http_post']['type'] ?? '') == 'receive_sms' ? 'selected' : '' ?>>Réception d'un SMS</option>
|
||||
<option value="send_sms" <?= ($_SESSION['previous_http_post']['type'] ?? '') == 'send_sms' ? 'selected' : '' ?>>Envoi d'un SMS</option>
|
||||
</select>
|
||||
</div>
|
||||
<a class="btn btn-danger" href="<?php echo \descartes\Router::url('Webhook', 'list'); ?>">Annuler</a>
|
||||
|
|
Loading…
Reference in New Issue