PHPackages                             taylornetwork/laravel-dynamic-form - 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. taylornetwork/laravel-dynamic-form

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

taylornetwork/laravel-dynamic-form
==================================

338PHP

Since Dec 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/taylornetwork/laravel-dynamic-form)[ Packagist](https://packagist.org/packages/taylornetwork/laravel-dynamic-form)[ RSS](/packages/taylornetwork-laravel-dynamic-form/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Dynamic Form
====================

[](#laravel-dynamic-form)

This package lets you dynamically create forms for a Laravel application that can be easily filled out by a user.

I created this package to have better control over user form pages, questions and options.

*Note: both the package and readme are still a work in progress*

Install
-------

[](#install)

```
$ composer require taylornetwork/laravel-dynamic-form
```

Setup
-----

[](#setup)

Run migrations

```
$ php artisan migrate
```

Models
------

[](#models)

All models are in the namespace `TaylorNetwork\DynamicForm\Models`

### Form

[](#form)

The `Form` model allows you to define a form `key` and `title` and will provide all related models below.

### Page

[](#page)

The `Page` model allows you to define pages on the form. This can be useful if you have a lot of questions to ask the user. Forms need at least 1 page.

Pages are numbered automatically when you use the `addPage` method (see Usage below)

Pages can have a title that will be displayed to the user.

### Question

[](#question)

The `Question` model is the actual question that will be shown to the user. You can specify the a few different question types.

**Currently supported types**

- `text` (default)
- `textarea`
- `select`
- `select multiple`
- `select multiple taggable` (select multiple but can include user defined values)

### Option

[](#option)

The `Option` model is only used if the question type is one that includes `select`. It allows you to set options to be used for the select controls

Usage
-----

[](#usage)

For example you want to create a multiple page form that asks the user about themselves and their home.

#### Create a new form

[](#create-a-new-form)

```
Form::create([ 'key' => 'user-info', 'title' => 'User Information Form' ]);
```

#### Fetch a form by key

[](#fetch-a-form-by-key)

You can use the `fetch` method on the `Form` model to fetch a form by key or you can use the `get_form_data` helper function.

```
Form::fetch('user-info');

get_form_data('user-info');
```

#### Add a page

[](#add-a-page)

Use the `addPage` method to add a new page to a form. Forms need at least 1 page. The `addPage` method will automatically increment the page numbers. It accepts an optional parameter that is the title of the page.

```
Form::fetch('user-info')->addPage('Information about you');

Form::fetch('user-info')->addPage();
```

#### Add questions

[](#add-questions)

Use the `addQuestion` method to add a question to a page of a form.

```
Form::fetch('user-info')->page(1)->addQuestion('What is your name?');

Form::fetch('user-info')->page(1)->addQuestion('What is your email address?');

Form::fetch('user-info')->page(1)->addQuestion('Tell us something interesting about you?', 'textarea');
```

#### Add questions with options

[](#add-questions-with-options)

Basic options:

For basic options that the values to pass back are the same as the text shown to the user, use the `addOptions` method and pass an array to a question.

```
Form::fetch('user-info')->page(1)->addQuestion('Are you the home owner?', 'select')->addOptions([ 'Yes', 'No' ]);

Form::fetch('user-info')->page(1)->addQuestion('What colours are in your home?', 'select multiple taggable')->addOptions([ 'Yellow', 'Blue', 'Red' ]);
```

Options with different values:

For options that the values passed back are different than the text shown to the user, use the `addOption` method and pass the text as the first parameter and the value as the second.

The `addOption` method returns an instance of the `Option` model so you cannot chain multiple together.

```
$question = Form::fetch('user-info')->page(1)->addQuestion('What rooms need work?', 'select multiple');

$question->addOption('Bathroom', 'BATH');
$question->addOption('Living Room', 'LVRM');
$question->addOption('Bedroom', 'BDRM');
$question->addOption('Basement', 'BSMT');
```

VueJS Setup
-----------

[](#vuejs-setup)

If you want to use the VueJS modal included

Install required NPM dependencies

```
$ npm install --save vue-select sweetalert2
```

Publish VueJS component

```
$ php artisan vendor:publish --tag=form-components
```

Add the following line to your `resources/js/app.js` somewhere after `window.Vue = require('vue');`

```
Vue.component('dynamic-form', require('./components/DynamicForm.vue').default);
```

VueJS Usage
-----------

[](#vuejs-usage)

The Vue modal has 3 required props

- `id`: The modal ID, used to open the modal
- `form-data`: The actual form data, you can use the `get_form_data()` helper
- `post-route`: The route to post the saved data to

When the data is submitted the component will use make an `axios` POST request to the uri from `post-route`.

The POST data will be an object with keys being the `id` of the question and the value being the data entered. If using `select multiple` this will be an array if more than one item is selected.

### Basic Example

[](#basic-example)

```
Open Modal

```

Note: When passing the form data to the Vue component be sure to include the `:` to bind the data. T

#### Example POST Data

[](#example-post-data)

Based on example above.

```
{
	1: 'John Doe',
	2: 'johndoe@example.com',
	3: 'John Doe is not my real name.',
	4: 'Yes',
	5: [
			'Blue',
			'Red'
		],
	6: 'BDRM'
}
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/83340094473f0bf5b2cf062bf394df221a52a30aa0e21cd0a77302977d6393ce?d=identicon)[samueljtaylor](/maintainers/samueljtaylor)

---

Top Contributors

[![samyrataylor](https://avatars.githubusercontent.com/u/15961687?v=4)](https://github.com/samyrataylor "samyrataylor (12 commits)")

### Embed Badge

![Health badge](/badges/taylornetwork-laravel-dynamic-form/health.svg)

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

###  Alternatives

[components/mathjs

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.

15.0k3.8k](/packages/components-mathjs)[aura/payload-interface

An interface package for Domain Payload implementations.

13392.7k4](/packages/aura-payload-interface)

PHPackages © 2026

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