1. Go to this page and download the library: Download iyoworks/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/ */
// Set field with id 'gender' to have 3 options instead of 2.
$form->getField('gender')->options(['m'=>'Male', 'f'=>'Female', 'n'=>'Not Telling']);
// Remove the gender field
$form->remove('gender');
// Add last name after first name
$form->addAfter('first_name', 'last_name', 'text');
$form->addTextAfterFirstName('last_name');
$form->addBefore('last_name', 'first_name', 'text');
$form->addTextAfterLastName('first_name');
use Iyoworks\FormBuilder\Form;
use Iyoworks\FormBuilder\Field;
// Closure support for FormBuilder
$form = FormBuilder::form(function(Form $form) {
$form->url('users/create');
$form->addText('first_name');
$form->addSelect('gender'->options(['M'=>'Male', 'F'=>'Female']);
})->html();
echo $form->open(), $form->render(), $form->close();
# the same as
echo $form->html();
$form->addRow(function($form){
$form->addText('first_name', 'First Name')
->label('First Name')
->description('Enter your first name')
->columns(12);
$form->addText('last_name', 'Last Name')
->label('First Name')
->description('Enter your last name')
->columns(12);
});
$form->addEmail('email', 'Email Address')
$form->addSubmit('Submit')->addClass('btn btn-block btn-primary');
beforeForm(Form $form)
afterForm(Form $form)
beforeField(Form $form, Field $field)
afterField(Form $form, Field $field)
// Per-form Callbacks
$form->beforeField(function(Form $form, Field $field) {
// Use field settings to display your form nicely
return '<label>' . $field->label . '</label>';
});