PHP code example of weegosoft / bootstrap-form-builder

1. Go to this page and download the library: Download weegosoft/bootstrap-form-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

weegosoft / bootstrap-form-builder example snippets


use Weegosoft\Form\Bootstrap5\Form;

// Données d'exemple (tableau ou objet)
$data = ['email' => '[email protected]'];
$errors = ['email' => 'Adresse email déjà utilisée.'];

$form = new Form($data, $errors);

echo $form->open('/register', 'POST', true, [], 'csrf_token_here');

echo $form->text('username', 'Nom d\'utilisateur', ['placeholder' => 'johndoe']);
echo $form->email('email', 'Adresse Email');
echo $form->switch('notifications', 'Activer les notifications', 1);

echo $form->submit('Inscrire', ['class' => 'btn btn-primary', 'icon' => 'fas fa-user-plus']);
echo $form->close();

use Weegosoft\Form\Form; // Ou Weegosoft\Form\Bootstrap4\Form;

$form = new Form(['role' => 'admin']);

echo $form->open('/profile/update', 'POST');
echo $form->text('username', 'Nom d\'utilisateur');
echo $form->select('role', 'Rôle', [
    'admin' => 'Administrateur',
    'editor' => 'Éditeur',
    'user' => 'Utilisateur'
]);
echo $form->currency('price', 'Prix de vente', 'FCFA');
echo $form->submit('Mettre à jour');
echo $form->close();

use Weegosoft\Form\Tailwind\Form;

$form = new Form();

echo $form->open('/settings', 'POST', false, ['class' => 'space-y-4']);
echo $form->text('title', 'Titre de l\'application');
echo $form->submit('Enregistrer');
echo $form->close();