1. Go to this page and download the library: Download litepie/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/ */
// Tabbed interface
$container->tabbed(true)->activeForm('step1');
// Accordion interface
$container->accordion(true);
// Stacked interface (default)
// Forms displayed one after another
// Individual validation (default) - each form validated separately
$container->validationMode('individual');
// Combined validation - all forms must pass
$container->validationMode('combined');
// Sequential validation - stops at first failure
$container->validationMode('sequential');
class RegistrationContainer extends \Litepie\Form\FormContainer
{
public function __construct($app)
{
parent::__construct($app, 'registration');
$this->setupRegistrationForms();
}
protected function setupRegistrationForms(): void
{
$this->name('User Registration')
->tabbed(true)
->validationMode('sequential');
// Step 1: Personal Information
$personal = $this->createForm('personal', [
'title' => 'Personal Information',
'icon' => 'user'
]);
$personal
->add('first_name', 'text', [' return (int)(($currentStep + 1) / $totalSteps * 100);
}
}
// Usage
$registrationContainer = new RegistrationContainer(app());
echo $registrationContainer->render();
class ContactController extends Controller
{
public function create()
{
$form = Form::create()
->action(route('contact.store'))
->method('POST')
->add('name', 'text', ['uest)
{
// Form validation is automatic
$validated = $request->validate([
'name' => '
// Convert existing form to array
$form = Form::create()
->add('name', 'text', ['formJson = $form->toJson();
// Or use helper functions
$formArray = form_array([
'name' => ['type' => 'text', 'label' => 'Name', '
// Return form schema as JSON for Vue/React/Angular
Route::get('/api/forms/contact', function() {
return form_array([
'name' => ['type' => 'text', 'label' => 'Name', ' 'action' => '/api/contact',
'method' => 'POST'
]);
});