Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
/build
/laravel
/node_modules
/vendor
.php-cs-fixer.cache
.phpunit.result.cache
composer.lock
# Only use pnpm for development
package-lock.json

Expand Down
141 changes: 1 addition & 140 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,17 @@
# Laravel Form Builder

Drag-and-drop form builder for Laravel + Vue 3. Define form schemas in an admin UI (`FormBuilder`), then render and collect submissions with `VForm`.
Drag-and-drop form builder for Vue 3. Define form schemas in an admin UI (`FormBuilder`), then render and collect submissions with `VForm`.

| Package | Purpose |
|---------|---------|
| `dcodegroup/form-builder` | Laravel models, migrations, validation helpers |
| `@dcodegroup-au/form-builder` | Vue components and styles |

## Requirements

- PHP 8.2+
- Laravel 11, 12, or 13 (package 3.x)
- Vue 3
- Node.js (for building or consuming the frontend package)

## Installation

### Version support

| Version / Branch | Laravel | Install |
|------------------|---------|---------|
| 1.x | ≤ 10 | `composer require dcodegroup/form-builder:^1.0` |
| 2.x | ≥ 11 | `composer require dcodegroup/form-builder:^2.0` |
| 3.x | ≥ 11 | `composer require dcodegroup/form-builder:^3.0` |

### Backend

```bash
composer require dcodegroup/form-builder:^3.0
php artisan form-builder:install
php artisan migrate
```

`form-builder:install` publishes the `forms` and `form_data` migrations when they are not already present.

### Frontend

```bash
npm install @dcodegroup-au/form-builder
```
Expand Down Expand Up @@ -143,98 +119,6 @@ const errors = ref({}) // Laravel validation errors bag

---

## Field types

Built-in components available in the palette:

| Type | Label |
|------|-------|
| `grid` | Grid (multi-column / row layout) |
| `heading` | Heading |
| `paragraph` | Paragraph |
| `text` | Input Field |
| `textarea` | Text Area |
| `number` | Number |
| `address` | Address |
| `datepicker` | Date Picker |
| `select` | Select |
| `checkbox` | Single Checkbox |
| `check-group` | Checkbox Group |
| `radio-group` | Radio Button Group |
| `signature` | Signature |
| `file-upload` | File Upload |

---

## Backend models & traits

### `Form`

Stores the form definition (`title`, `recipients`, `status`, `published_at`, `fields`).

```php
use Dcodegroup\FormBuilder\Models\Form;

$form = Form::saveModel([
'title' => 'Onboarding',
'status' => 'published',
'fields' => $request->input('data.fields'),
]);
```

### `FormData`

Stores a filled submission (`values`, `completed_at`) morph-linked to any model via `formable`, and related to a `Form`.

### `HasFilledForms`

Add to any Eloquent model that can have filled forms:

```php
use Dcodegroup\FormBuilder\Models\Traits\HasFilledForms;

class Job extends Model
{
use HasFilledForms;
}

// Latest (or create) submission for a form
$formData = $job->getFormData($form, createNew: true);

// Persist values
$job->saveFormData($form, $values);
```

### `FormValidator`

Use on a Form Request to build rules from required fields in the schema:

```php
use Dcodegroup\FormBuilder\Http\Traits\FormValidator;
use Illuminate\Foundation\Http\FormRequest;

class StoreFormSubmissionRequest extends FormRequest
{
use FormValidator;

public function rules(): array
{
return $this->getRules([
// extra static rules...
]);
}

public function messages(): array
{
return $this->getRules([], isMessage: true);
}
}
```

Rules are derived from `route('form')?->fields` when present, otherwise from `request()->input('data.fields')`.

---

## Custom field components

Register custom builder + presenter pairs on the Vue app. They appear in the component palette and render in `VForm`.
Expand Down Expand Up @@ -310,29 +194,6 @@ The package ships compiled CSS. Source styles use **Tailwind CSS v3** with **v4-

---

## Database

**`forms`**

| Column | Notes |
|--------|--------|
| `title` | Form name |
| `recipients` | JSON (notification emails) |
| `status` | e.g. draft / published |
| `published_at` | Set when published |
| `fields` | JSON schema |

**`form_data`**

| Column | Notes |
|--------|--------|
| `formable_type` / `formable_id` | Morph to the owning model |
| `form_id` | Related `forms` row |
| `values` | JSON answers |
| `completed_at` | Nullable completion timestamp |

---

## Development

Build the library assets from the package root:
Expand Down
56 changes: 0 additions & 56 deletions composer.json

This file was deleted.

36 changes: 0 additions & 36 deletions database/migrations/create_form_data_table.stub.php

This file was deleted.

38 changes: 0 additions & 38 deletions database/migrations/create_forms_table.stub.php

This file was deleted.

2 changes: 1 addition & 1 deletion dist/form-builder.css

Large diffs are not rendered by default.

Loading
Loading