LOForm

LOForm is a streamlined PHP class designed to simplify the creation and management of HTML forms. With its intuitive API, developers can easily define form fields, process submissions, and render consistent, well-structured form elements.

Whether you're building a basic contact form, a multi-step survey, or a form with specialized input types, LOForm delivers a flexible and scalable solution—all without the overhead of complex frameworks or heavy dependencies.

LOForm Demo

Input

Refresh the webpage to see a new example.

<?php

require_once 'loform.php';

$form = new LOForm();

if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST)) {
    $form->load($_POST);
    // Process survey results
    echo "<p>Thank you for completing our survey!</p>";
    exit;
}

$form->field([
    'type'  => 'hidden',
    'name'  => 'survey_id',
    'value' => 'survey_2025_001'
]);

$form->field([
    'type'  => 'text',
    'name'  => 'name',
    'title' => 'Your Name',
    'holder' => 'Optional'
]);

$form->field([
    'type'  => 'select',
    'name'  => 'satisfaction',
    'title' => 'How satisfied are you?',
    'options' => [
        '5' => 'Very satisfied',
        '4' => 'Satisfied',
        '3' => 'Neutral',
        '2' => 'Dissatisfied',
        '1' => 'Very dissatisfied'
    ],
    'default' => '3'
]);

$form->field([
    'type'  => 'textarea',
    'name'  => 'feedback',
    'title' => 'Additional Feedback',
    'holder' => 'Your comments...'
]);

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Customer Survey</title>
    <?php echo LOForm::header(); ?>
</head>
<body>
    <h1>Customer Satisfaction Survey</h1>
    <?php
    echo $form->form([
        'action' => '',
        'method' => 'post',
        'print'  => false
    ]);
    ?>
</body>
</html>
<?php
echo LOForm::footer();

Output

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Customer Survey</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/LacasuriOrtodoxe/LOEditor@latest/loeditor.min.css" />
    <script src="https://cdn.jsdelivr.net/gh/jquery/jquery@latest/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/LacasuriOrtodoxe/LOEditor@latest/loeditor.min.js"></script>
</head>

<body>
    <h1>Customer Satisfaction Survey</h1>
    <form action="" method="post">
        <div class="form-group">
            <input type="hidden" name="survey_id" id="input-q0hefxa" value="" />
        </div>
        <div class="form-group">
            <label for="input-rl62byv">Your Name</label>
            <input type="text" name="name" id="input-rl62byv" value="" placeholder="Optional" />
        </div>
        <div class="form-group">
            <label for="input-ygdfaoq">How satisfied are you?</label>
            <select name="satisfaction" id="input-ygdfaoq" placeholder="">
                <option value="5">Very satisfied</option>
                <option value="4">Satisfied</option>
                <option value="3" selected>Neutral</option>
                <option value="2">Dissatisfied</option>
                <option value="1">Very dissatisfied</option>
            </select>
        </div>
        <div class="form-group">
            <label for="input-9ksb0p8">Additional Feedback</label>
            <textarea name="feedback" id="input-9ksb0p8" placeholder="Your comments...">
            </textarea>
        </div>
        <button type="submit">Submit</button>
    </form>
</body>

</html>
<script>
    var textareas = document.querySelectorAll(".loeditor");
            for(i=0;i<textareas.length;i++) {
            console.log(textareas[i])
               new LOEditor(textareas[i], {
                   upload: "upload.php"
               });
            }
</script>