PHPackages                             hyderkamran/laravel-form-builder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hyderkamran/laravel-form-builder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hyderkamran/laravel-form-builder
================================

A production-ready, dynamic form builder package for Laravel — drag-and-drop admin UI, 21 field types, conditional logic, file uploads, repeater fields, submissions export, and API support.

1.0.5(1mo ago)12101MITBladePHP ^7.3|^8.0

Since Jun 3Pushed 1mo agoCompare

[ Source](https://github.com/haider-kamran/laravel-form-builder)[ Packagist](https://packagist.org/packages/hyderkamran/laravel-form-builder)[ Docs](https://github.com/hyderkamran/laravel-form-builder)[ RSS](/packages/hyderkamran-laravel-form-builder/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (22)Versions (5)Used By (0)

Laravel Form Builder
====================

[](#laravel-form-builder)

 [![Packagist Version](https://camo.githubusercontent.com/07fc5b9db2d2605d890bf061b06bda4d2962c9bf976ab91302e4239a5626850c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68796465726b616d72616e2f6c61726176656c2d666f726d2d6275696c6465723f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/07fc5b9db2d2605d890bf061b06bda4d2962c9bf976ab91302e4239a5626850c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68796465726b616d72616e2f6c61726176656c2d666f726d2d6275696c6465723f7374796c653d666c61742d737175617265) [![License](https://camo.githubusercontent.com/a6aa7a431411987e8da1b145007a131b8456772707d3d19d7e7f621762d46af7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f68796465726b616d72616e2f6c61726176656c2d666f726d2d6275696c6465723f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/a6aa7a431411987e8da1b145007a131b8456772707d3d19d7e7f621762d46af7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f68796465726b616d72616e2f6c61726176656c2d666f726d2d6275696c6465723f7374796c653d666c61742d737175617265) [![PHP Version](https://camo.githubusercontent.com/a872f386f6cb9f1d860598582feb556490affe2aabd1e764ee2bb56c3eb0a6a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f68796465726b616d72616e2f6c61726176656c2d666f726d2d6275696c6465723f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/a872f386f6cb9f1d860598582feb556490affe2aabd1e764ee2bb56c3eb0a6a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f68796465726b616d72616e2f6c61726176656c2d666f726d2d6275696c6465723f7374796c653d666c61742d737175617265) [![Laravel Version](https://camo.githubusercontent.com/7f5e84905540210af5e0c64118365b1819b8b51376bcb30af615a339c61d8f52/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d313025323025374325323031312d6f72616e67653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/7f5e84905540210af5e0c64118365b1819b8b51376bcb30af615a339c61d8f52/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d313025323025374325323031312d6f72616e67653f7374796c653d666c61742d737175617265)

> A dynamic, database-driven form builder for Laravel. Inspired by Typeform, Google Forms, and WPForms — built for developers.

---

[![Forms Listing](image1.png)](image1.png)[![Add From](image-12.png)](image-12.png)

Features
--------

[](#features)

FeatureStatus21 field types (text → repeater)✅Drag-and-drop admin UI✅Database-driven form definitions✅Dynamic validation (per-field rules)✅Conditional field logic (show/hide)✅File &amp; image upload support✅Repeater fields (nested rows)✅Form submissions with export (CSV/Excel/PDF)✅Email notifications on submission✅Webhook support✅API endpoints (JSON)✅Embeddable `` mode✅Blade directive `@form('slug')`✅Caching layer✅PSR-4, Laravel package conventions✅---

Requirements
------------

[](#requirements)

- PHP `^8.1`
- Laravel `^10.0 | ^11.0`

---

Installation
------------

[](#installation)

```
composer require hyderkamran/laravel-form-builder
```

The service provider and `FormBuilder` facade are auto-discovered by Laravel.

### Publish &amp; Migrate

[](#publish--migrate)

```
# Config
php artisan vendor:publish --tag=form-builder-config

# Migrations
php artisan vendor:publish --tag=form-builder-migrations
php artisan migrate

# Frontend assets (JS for drag-and-drop + conditional logic)
php artisan vendor:publish --tag=form-builder-assets

# (Optional) Views — only if you need to customise Blade templates
php artisan vendor:publish --tag=form-builder-views

# (Optional) Demo seeders
php artisan vendor:publish --tag=form-builder-seeders
php artisan db:seed --class=FormBuilderSeeder
```

---

Configuration
-------------

[](#configuration)

`config/form-builder.php`:

```
return [
    'storage_disk'             => 'public',        // disk for file uploads
    'export_format'            => ['csv', 'xlsx', 'pdf'],
    'enable_notifications'     => true,
    'notification_recipients'  => [],              // fallback emails
    'admin_middleware'         => ['web'],          // add 'auth' to protect
    'cache_ttl'                => 3600,            // seconds; 0 = disabled
    'upload' => [
        'max_size_kb'   => 10240,
        'allowed_mimes' => ['jpeg', 'png', 'pdf', 'docx', ...],
    ],
];
```

You can also use `.env` variables:

```
FORM_BUILDER_DISK=public
FORM_BUILDER_NOTIFICATIONS=true
FORM_BUILDER_RECIPIENTS=admin@example.com,support@example.com
FORM_BUILDER_CACHE_TTL=3600
```

---

Usage
-----

[](#usage)

### Creating a Form (Programmatic)

[](#creating-a-form-programmatic)

```
use Hyderkamran\FormBuilder\Models\Form;
use Hyderkamran\FormBuilder\Models\FormField;
use Hyderkamran\FormBuilder\Enums\FieldType;

$form = Form::create([
    'title'       => 'Contact Us',
    'slug'        => 'contact-us',
    'description' => 'We would love to hear from you.',
    'is_active'   => true,
]);

FormField::create([
    'form_id'          => $form->id,
    'label'            => 'Full Name',
    'name'             => 'name',
    'type'             => FieldType::Text->value,
    'is_required'      => true,
    'order'            => 0,
]);

FormField::create([
    'form_id'          => $form->id,
    'label'            => 'Email',
    'name'             => 'email',
    'type'             => FieldType::Email->value,
    'is_required'      => true,
    'order'            => 1,
    'validation_rules' => ['email' => 'rfc'],
]);

FormField::create([
    'form_id'     => $form->id,
    'label'       => 'Country',
    'name'        => 'country',
    'type'        => FieldType::Select->value,
    'is_required' => true,
    'order'       => 2,
    'options'     => [
        'choices' => ['pk' => 'Pakistan', 'us' => 'United States', 'uk' => 'United Kingdom'],
    ],
]);
```

### Rendering in Blade

[](#rendering-in-blade)

```
{{-- Blade directive --}}
@form('contact-us')

{{-- Or via Facade --}}
{!! FormBuilder::render('contact-us') !!}
```

### Embedding via ``

[](#embedding-via-iframe)

```

```

---

Field Types
-----------

[](#field-types)

GroupTypes**Basic**`text`, `email`, `number`, `textarea`, `password`, `hidden`, `url`, `tel`**Choice**`select`, `radio`, `checkbox`, `toggle`**Date &amp; Time**`date`, `datetime`, `time`**Media**`file`, `image`**Special**`range`, `color`, `rating`**Pro**`repeater`Access via enum:

```
use Hyderkamran\FormBuilder\Enums\FieldType;

FieldType::Rating->label();   // "Star Rating"
FieldType::Rating->icon();    // "bi-star"
FieldType::Rating->group();   // "Special"
FieldType::grouped();         // ['Basic' => [...], 'Choice' => [...], ...]
```

---

Conditional Logic
-----------------

[](#conditional-logic)

Show or hide a field based on another field's value. Set via `options['logic']`:

```
FormField::create([
    // ... other attributes
    'options' => [
        'logic' => [
            'field'    => 'country',   // watch this field
            'operator' => '=',         // =, !=, >,  'pk',        // match this value
            'action'   => 'show',      // 'show' or 'hide'
        ],
    ],
]);
```

This is also configurable in the drag-and-drop admin UI under the **Logic** tab.

---

Repeater Fields
---------------

[](#repeater-fields)

A repeater allows nested, dynamic row-based data:

```
FormField::create([
    'form_id' => $form->id,
    'label'   => 'Work Experience',
    'name'    => 'experience',
    'type'    => FieldType::Repeater->value,
    'options' => [
        'fields' => [
            ['name' => 'company', 'label' => 'Company', 'type' => 'text',   'required' => true, 'width' => 6],
            ['name' => 'role',    'label' => 'Role',    'type' => 'text',   'required' => true, 'width' => 6],
            ['name' => 'years',   'label' => 'Years',   'type' => 'number', 'required' => false, 'width' => 12],
        ],
    ],
]);
```

---

Exporting Submissions
---------------------

[](#exporting-submissions)

```
use Hyderkamran\FormBuilder\Services\FormExporter;

// By slug or ID:
FormExporter::toCSV('contact-us');
FormExporter::toExcel('contact-us');
FormExporter::toPdf('contact-us');
```

Or hit the admin export routes directly:

```
GET /forms/admin/{id}/export/csv
GET /forms/admin/{id}/export/xlsx
GET /forms/admin/{id}/export/pdf

```

---

API Endpoints
-------------

[](#api-endpoints)

```
GET  /api/form-builder/forms/{slug}        → Form schema (JSON)
POST /api/form-builder/forms/{slug}/submit → Submit (JSON)

```

### Submit example (cURL):

[](#submit-example-curl)

```
curl -X POST https://your-app.com/api/form-builder/forms/contact-us/submit \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"name": "Alice", "email": "alice@example.com"}'
```

---

Notifications &amp; Webhooks
----------------------------

[](#notifications--webhooks)

Configure per-form in the admin panel **Settings** tab or via `Form::settings`:

```
$form->update([
    'settings' => [
        'enable_notifications'     => true,
        'notification_recipients'  => ['admin@example.com'],
        'webhook_enabled'          => true,
        'webhook_url'              => 'https://hooks.example.com/form',
    ]
]);
```

---

HasForms Trait
--------------

[](#hasforms-trait)

```
use Hyderkamran\FormBuilder\Traits\HasForms;

class Contact extends Model
{
    use HasForms;
}

// Attach a form to any model via polymorphic relation:
$contact->forms()->attach($form->id);
```

---

Admin UI
--------

[](#admin-ui)

Visit `/forms/admin` in your browser.

PageURLDashboard`/forms/admin`Create Form`/forms/admin/create`Edit Form`/forms/admin/{id}/edit`Submissions`/forms/admin/{id}/submissions`> To protect the admin with auth, set `admin_middleware` → `['web', 'auth']` in your config.

---

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

The test suite covers:

- Form &amp; field model creation
- Submission validation (required, email, custom rules)
- File upload handling
- Form rendering output
- CSV export response headers
- Admin CRUD endpoints
- FieldType enum

---

Package Structure
-----------------

[](#package-structure)

```
laravel-form-builder/
├── config/form-builder.php
├── database/
│   ├── migrations/
│   └── seeders/FormBuilderSeeder.php
├── resources/
│   ├── views/
│   │   ├── admin/          ← Admin UI (layout, index, form_edit, submissions)
│   │   ├── fields/         ← 21 field blade templates
│   │   ├── emails/         ← Email notification template
│   │   ├── exports/        ← PDF export template
│   │   ├── form.blade.php
│   │   └── form-embed.blade.php
│   └── js/
│       ├── admin.js        ← Drag-and-drop builder engine
│       └── form-builder.js ← Conditional logic + repeater JS
├── routes/
│   ├── web.php
│   └── api.php
├── src/
│   ├── Enums/FieldType.php
│   ├── Events/
│   ├── Facades/FormBuilder.php
│   ├── Http/Controllers/
│   ├── Mail/
│   ├── Models/
│   ├── Services/
│   ├── Traits/HasForms.php
│   ├── FormBuilder.php
│   └── FormBuilderServiceProvider.php
└── tests/Feature/FormBuilderTest.php

```

---

Contributing
------------

[](#contributing)

Pull requests are welcome. Please open an issue first to discuss what you would like to change.

---

License
-------

[](#license)

MIT License — see [LICENSE](LICENSE) for details.

---

Built for the Laravel community.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance90

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

51d ago

PHP version history (3 changes)1.0.0PHP ^8.1

1.0.1PHP ^8.2

1.0.4PHP ^7.3|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3443560?v=4)[Syed Kamran Haider](/maintainers/kamranhaider)[@kamranhaider](https://github.com/kamranhaider)

---

Tags

laravelFormsdrag-and-dropform-builderdynamic formsform-submission

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hyderkamran-laravel-form-builder/health.svg)

```
[![Health](https://phpackages.com/badges/hyderkamran-laravel-form-builder/health.svg)](https://phpackages.com/packages/hyderkamran-laravel-form-builder)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M133](/packages/roots-acorn)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k30.2M151](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M136](/packages/laravel-pulse)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77922.3M186](/packages/laravel-mcp)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
