<!doctype html>
<html lang="fr">
<head>
    <meta charset="utf-8">
    <title>Formulaire</title>
    <style>
        body{font-family:Arial;padding:20px;}
        .row{margin-bottom:12px;}
        label{display:block;font-weight:bold;}
        .error{color:#c00;font-size:14px;}
    </style>
</head>
<body>

<h2>Formulaire : <?= html_escape($form_key) ?></h2>

<?= validation_errors('<div class="error">', '</div>') ?>

<form method="post" action="<?= site_url('DynamicForm/submit/'.$form_key) ?>">

    <?php foreach ($fields as $f): ?>
        <div class="row">
            <label><?= html_escape($f['label']) ?></label>
            <input
                type="<?= html_escape($f['type']) ?>"
                name="<?= html_escape($f['name']) ?>"
                value="<?= set_value($f['name']) ?>"
            >
        </div>
    <?php endforeach; ?>

    <button type="submit">Envoyer</button>
</form>

</body>
</html>
