PHP code example of bupy7 / php-html-form

1. Go to this page and download the library: Download bupy7/php-html-form 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/ */

    

bupy7 / php-html-form example snippets


$builder = new AdamWathan\Form\FormBuilder;

// <input type="text" name="email" value="[email protected]" uired(); 

// <form method="POST">
<?= $builder->open(); 

// <input type="text" name="email">
<?= $builder->text('email'); 

// <textarea name="bio" rows="5" cols="50"></textarea>
<?= $builder->textarea('bio')->rows(5); 

// <input type="checkbox" name="terms" value="1">
<?= $builder->checkbox('terms'); 

// <select name="birth_year"></select>
<?= $builder->select('birth_year'); 

// <button type="button">Click Me</button>
<?= $builder->button('Click Me'); 

// <input type="hidden" name="secret" value="my-secret-value">
<?= $builder->hidden('secret')->value('my-secret-value'); 

// <label>Email</label>
<?= $builder->label('Email'); 

// <label>Email<input type="text" name="email"></label>
<?= $builder->label('Email')->before($emailElement); 

// Attributes can be set with attribute(...)
// <input type="text" name="foobar" min="4">
<?= $builder->text('foobar')->attribute('min', 4); 

$builder->setErrorStore($myErrorStore);

// Check if the form has an error for an element
$builder->hasError('email');

// Retrieve the error message for an element
$builder->getError('email');

 if ($builder->hasError('email')): 

<?= $builder->getError('email', '<span class="error">:message</span'); 

<?= $builder->token(); 

$model->first_name = "John";
$model->last_name = "Doe";
$model->email = "[email protected]";

<?= $builder->open(); 

~/.composer/vendor/bin/php-cs-fixer fix --config=./phpcs.php --verbose

composer global