Deltacms/module/form/view/index/index.php

95 lines
3.6 KiB
PHP
Raw Normal View History

2022-03-06 13:35:21 +01:00
<?php
// Lexique
$text = [];
$val = $this->getData(['config', 'i18n', 'langAdmin']);
switch ($val) {
case 'fr' :
$text[0] = 'Envoyer';
$text[1] = 'Le formulaire ne contient aucun champ.';
break;
case 'en' :
$text[0] = 'Send';
$text[1] = 'The form contains no fields';
break;
}
?>
2022-01-31 09:10:49 +01:00
<?php if($this->getData(['module', $this->getUrl(0), 'input'])): ?>
2022-05-01 11:45:17 +02:00
<?php echo template::formOpenFile('formForm'); ?>
2022-01-31 09:10:49 +01:00
<?php foreach($this->getData(['module', $this->getUrl(0), 'input']) as $index => $input): ?>
<?php if($input['type'] === $module::TYPE_MAIL): ?>
<?php echo template::mail('formInput[' . $index . ']', [
'id' => 'formInput_' . $index,
2022-05-01 11:45:17 +02:00
'label' => $input['name'],
'value' => $this->getData([ 'module', $this->getUrl(0), 'draft', 'mail'])
2022-01-31 09:10:49 +01:00
]); ?>
<?php elseif($input['type'] === $module::TYPE_SELECT): ?>
<?php
$values = array_flip(explode(',', $input['values']));
foreach($values as $value => $key) {
$values[$value] = trim($value);
}
?>
<?php echo template::select('formInput[' . $index . ']', $values, [
'id' => 'formInput_' . $index,
2022-05-01 11:45:17 +02:00
'label' => $input['name'],
'value' => $this->getData([ 'module', $this->getUrl(0), 'draft', 'select'])
2022-01-31 09:10:49 +01:00
]); ?>
<?php elseif($input['type'] === $module::TYPE_TEXT): ?>
<?php echo template::text('formInput[' . $index . ']', [
'id' => 'formInput_' . $index,
2022-05-01 11:45:17 +02:00
'label' => $input['name'],
'value' => $this->getData([ 'module', $this->getUrl(0), 'draft', 'text'])
2022-01-31 09:10:49 +01:00
]); ?>
<?php elseif($input['type'] === $module::TYPE_TEXTAREA): ?>
<?php echo template::textarea('formInput[' . $index . ']', [
'id' => 'formInput_' . $index,
2022-05-01 11:45:17 +02:00
'label' => $input['name'],
'value' => $this->getData([ 'module', $this->getUrl(0), 'draft', 'textarea'])
2022-01-31 09:10:49 +01:00
]); ?>
<?php elseif($input['type'] === $module::TYPE_DATETIME): ?>
<?php echo template::date('formInput[' . $index . ']', [
'id' => 'formInput_' . $index,
'label' => $input['name'],
2022-05-01 11:45:17 +02:00
'vendor' => 'flatpickr',
'value' => $this->getData([ 'module', $this->getUrl(0), 'draft', 'datetime'])
2022-01-31 09:10:49 +01:00
]); ?>
<?php elseif($input['type'] === $module::TYPE_CHECKBOX): ?>
2022-05-01 11:45:17 +02:00
<?php echo template::checkbox('formInput[' . $index . ']', true, $input['name'], [
'checked' => $this->getData([ 'module', $this->getUrl(0), 'draft', 'checkbox'])
]); ?>
<?php elseif($input['type'] === $module::TYPE_FILE): ?>
<label class='formLabel'> <?php echo $input['name']; ?> </label>
<div class="formInputFile">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000">
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="button" id="formFileReset" value="X">
</div><br>
2022-01-31 09:10:49 +01:00
<?php elseif($input['type'] === $module::TYPE_LABEL): ?>
2022-05-01 11:45:17 +02:00
<p class='formLabel'> <?php echo $input['name']; ?> </p>
2022-01-31 09:10:49 +01:00
<?php endif; ?>
<?php endforeach; ?>
<?php if($this->getData(['module', $this->getUrl(0), 'config', 'captcha'])): ?>
<div class="row">
<div class="col12 textAlignCenter">
<?php echo template::captcha('formCaptcha', [
'limit' => $this->getData(['config','connect', 'captchaStrong']),
'type' => $this->getData(['config','connect', 'captchaType'])
]); ?>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col2 offset10">
<?php echo template::submit('formSubmit', [
2022-03-06 13:35:21 +01:00
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'button']) ? $this->getData(['module', $this->getUrl(0), 'config', 'button']) : $text[0],
2022-01-31 09:10:49 +01:00
'ico' => ''
]); ?>
</div>
</div>
<?php echo template::formClose(); ?>
<?php else: ?>
2022-03-06 13:35:21 +01:00
<?php echo template::speech($text[1]); ?>
2022-01-31 09:10:49 +01:00
<?php endif; ?>