ZwiiCMS/module/form/view/index/index.php

80 lines
3.1 KiB
PHP
Raw Normal View History

2023-01-27 08:26:34 +01:00
<?php if ($this->getData(['module', $this->getUrl(0), 'input'])): ?>
<div class="row <?php echo $this->getData(['module', $this->getUrl(0), 'config', 'align']); ?>">
<div class="<?php
2022-02-18 12:43:48 +01:00
echo 'col' . $this->getData(['module', $this->getUrl(0), 'config', 'width']) . ' ';
echo $this->getData(['module', $this->getUrl(0), 'config', 'offset']) !== 0 ? 'offset' . $this->getData(['module', $this->getUrl(0), 'config', 'offset']) : '';
2023-01-27 08:26:34 +01:00
?>">
<?php echo template::formOpen('formForm'); ?>
<?php foreach ($this->getData(['module', $this->getUrl(0), 'input']) as $index => $input): ?>
<?php if ($input['type'] === $module::TYPE_MAIL): ?>
2022-02-18 12:43:48 +01:00
<?php echo template::mail('formInput[' . $index . ']', [
'id' => 'formInput_' . $index,
'label' => $input['name']
]); ?>
2023-01-27 08:26:34 +01:00
<?php elseif ($input['type'] === $module::TYPE_SELECT): ?>
2022-02-18 12:43:48 +01:00
<?php
2023-07-25 11:07:55 +02:00
$values = array_flip(explode(',', $input['values']));
foreach ($values as $value => $key) {
2022-02-18 12:43:48 +01:00
$values[$value] = trim($value);
}
?>
<?php echo template::select('formInput[' . $index . ']', $values, [
'id' => 'formInput_' . $index,
'label' => $input['name']
]); ?>
2023-01-27 08:26:34 +01:00
<?php elseif ($input['type'] === $module::TYPE_TEXT): ?>
2022-02-18 12:43:48 +01:00
<?php echo template::text('formInput[' . $index . ']', [
'id' => 'formInput_' . $index,
'label' => $input['name']
]); ?>
2023-01-27 08:26:34 +01:00
<?php elseif ($input['type'] === $module::TYPE_TEXTAREA): ?>
2022-02-18 12:43:48 +01:00
<?php echo template::textarea('formInput[' . $index . ']', [
'id' => 'formInput_' . $index,
'label' => $input['name']
]); ?>
2023-01-27 08:26:34 +01:00
<?php elseif ($input['type'] === $module::TYPE_DATETIME): ?>
2022-02-18 12:43:48 +01:00
<?php echo template::date('formInput[' . $index . ']', [
'id' => 'formInput_' . $index,
'label' => $input['name'],
2023-02-17 10:59:25 +01:00
'type' => 'date',
2022-02-18 12:43:48 +01:00
]); ?>
2023-01-27 08:26:34 +01:00
<?php elseif ($input['type'] === $module::TYPE_CHECKBOX): ?>
<?php echo template::checkbox(
'formInput[' . $index . ']',
true, $input['name']
2022-02-18 12:43:48 +01:00
); ?>
2023-01-27 08:26:34 +01:00
<?php elseif ($input['type'] === $module::TYPE_LABEL): ?>
2022-02-18 12:43:48 +01:00
<h3 class='formLabel'>
<?php echo $input['name']; ?>
<hr class="formLabel">
</h3>
<?php endif; ?>
<?php endforeach; ?>
2023-07-25 11:07:55 +02:00
</div>
</div>
<div class="row">
<div class="col12 textAlignCenter">
2023-01-27 08:26:34 +01:00
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'captcha'])): ?>
2022-02-18 12:43:48 +01:00
<div class="row">
<div class="col12 textAlignCenter">
<?php echo template::captcha('formCaptcha', [
2023-01-27 08:26:34 +01:00
'limit' => $this->getData(['config', 'connect', 'captchaStrong']),
'type' => $this->getData(['config', 'connect', 'captchaType'])
2022-02-18 12:43:48 +01:00
]); ?>
</div>
</div>
2018-04-02 08:29:19 +02:00
<?php endif; ?>
<div class="row">
2023-07-25 11:07:55 +02:00
<div class="col2">
2022-02-18 12:43:48 +01:00
<?php echo template::submit('formSubmit', [
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'button']) ? $this->getData(['module', $this->getUrl(0), 'config', 'button']) : 'Envoyer',
'ico' => ''
2020-10-11 19:29:33 +02:00
]); ?>
2018-04-02 08:29:19 +02:00
</div>
</div>
</div>
2022-02-18 12:43:48 +01:00
</div>
2023-01-27 08:26:34 +01:00
<?php echo template::formClose(); ?>
2018-04-02 08:29:19 +02:00
<?php else: ?>
<?php echo template::speech('Le formulaire ne contient aucun champ.'); ?>
<?php endif; ?>