Git Product home page Git Product logo

laravel-formbuilder's Introduction

Laravel Form Builder Package

Note: THIS PACKAGE MAY NOT B COMPATIBLE WITH LARAVEL 7 or 8. I am no longer maintaining this package so please use the code for reference on how to create a jquery form builder.

A Laravel package for creating a drag-and-drop form builder using the JQuery Form Builder.

Demo: http://demoform.jazmy.com/

Note: Features like email, registration and file uploads are disabled in the demo

Screenshot:

alt text

The forms fields are saved as json and stored in your database. A member of your site can create, edit and delete forms. Forms belong to the users that created them and each form has a unique link that can be shared publicly.

The json version of the form can be used to render the form for users to fill.

Example Json Form:

[{"type":"header","subtype":"h1","label":"Demo Form 01"},{"type":"paragraph","subtype":"p","label":"This demo form is a potluck sign-up sheet"},{"type":"text","label":"Name","className":"form-control","name":"name","subtype":"text"},{"type":"radio-group","label":"Food Category","name":"foodcategory","other":true,"values":[{"label":"Appetizer","value":"Appetizer"},{"label":"Beverage","value":"Beverage"},{"label":"Salad","value":"Salad"},{"label":"Main","value":"Main"},{"label":"Dessert","value":"Dessert"}]},{"type":"number","label":"How many will it serve","className":"form-control","name":"numberserved","min":"1","max":"50","step":"1"},{"type":"text","label":"Dish Name","className":"form-control","name":"dishname","subtype":"text"},{"type":"checkbox-group","label":"Dietary Restrictions","description":"Which of the following does your dish contain?","name":"dietaryrestrictions","values":[{"label":"Alcohol","value":"Alcohol"},{"label":"Carbs","value":"Carbs"},{"label":"Dairy","value":"Dairy"},{"label":"Egg","value":"Egg"},{"label":"Fish","value":"Fish"},{"label":"Gluten","value":"Gluten"}]},{"type":"textarea","label":"Comment","className":"form-control","name":"comment","subtype":"textarea"}]

Form permission options

  • Public - anyone can submit the form without needing to login
  • Private - only authenticated members of your site can access the form. Provide the option for users to edit their previous submissions.

Requirements

If you are looking for a managed web host, with easy laravel site creation, then I highly recommend Cloudways. Cloudways will setup a laravel site and mysql database in minutes.

Dependencies Included with Package

Installation Instructions

This custom package takes a couple steps to install but I will try to make it as simple as possible.

Step One:

Edit your composer.json file manually or simply type

composer require jazmy/jaz-form-builder

Step Two:

Ensure you have all your dependencies installed

composer install

Note: The package will automatically register itself using Laravel's package discovery feature for versions 5.6 and above. This means you do not need to update your config/app.php file.

Step Three:

We need to add the additional database tables so run the following command

php artisan migrate

Step Four:

Create the form package's configuration file. This will place a formbuilder.php file in your config folder. In the configuration file you can change the url path for the package's routes, layout template to use and script / style output sections.

Run the following command:

php artisan vendor:publish --tag formbuilder-config

Step Five:

Update your blade template file. In the default laravel install the template file is located here: /resources/views/layouts/app.blade.php

You need to add tags for the new styles and scripts At the top of the blade file, just above the closing head tag:

@stack('styles')

At the bottom of the blade file, just above the closing the closing body tag:

@stack('scripts')

Note: If you ever need to change which files are called using these @stack values, you can update the config file.

Step Six:

Publish the custom blade view files by running

php artisan vendor:publish --tag formbuilder-views

Publish the public assets by running

php artisan vendor:publish --tag formbuilder-public

Or you can publish everything at once with

php artisan vendor:publish --provider="jazmy\FormBuilder\FormBuilderServiceProvider"

Step Seven:

In order to properly link to attachments, you need to run the storage:link command which makes the storage folder publicly accessibly

php artisan storage:link

Accessing The Application

Ta Da! You did it! Now to access the form application. http://your.domain.com/form-builder/forms

To view submissions: http://your.domain.com/form-builder/my-submissions

Using The Trait

You can access forms and submissions that belong to a user in your application. To use the trait add a use statement to your user model class.

use jazmy\FormBuilder\Traits\HasFormBuilderTraits;

class User extends Authenticatable
{
    use HasFormBuilderTraits;
}

You can now access the user's forms and submissions by running

$user = User::first();

// get the user's forms
$user->forms;

// get the user's submissions
$user->submissions;

// or use static methods on the jazmy\FormBuilder\Models\Form class
$user_forms = Form::getForUser($user); // returns a paginated resultset

// the jazmy\FormBuilder\Models\Submission class also has a static method for getting the submissions
// that belong to a user
$my_submissions = Submission::getForUser($user); // returns a paginated resultset

Using Events

The package dispatches a number of events when records are created or updated so that you can listen to these events and perform custom tasks in your application's logic

Precautions

  1. Make sure you have a table name users with a colum id {bigSignedInteger} in your database.
  2. Once you have submission(s) on a form , dont attempt to edit the form again bacause it will break the display of earlier submissions 3.

Acknowledgments

Special Thanks to Farayola Oladele, one of the best Laravel programmers on Fiverr: https://www.fiverr.com/harristech He taught me so much and I highly recommend him for assistance on your Laravel projects.

laravel-formbuilder's People

Contributors

jazmy avatar jmroelofs avatar stevebaros avatar yaroslawww avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-formbuilder's Issues

Form is not getting update with fields on live server

Hi Team,

I have implemented this in localhost with prefix 'admin/form-builder' and its working fine.
But on live server its not working with or without 'admin' prefix for update form with fields as i can see the toolbar to update the form but once i click on save its giving error no 405.
I tried many things to fix it but still didn't get solution so please my humble request please help me to come out of it.

Waiting for your quick response.

Thanks.

Error Installing

When I run the command: composer require jazmy/jaz-form-builder

I got this error

You are using an outdated version of Composer. Composer 2.0 is about to be released and the older 1.x releases will self-u
pdate directly to it once it is released. To avoid surprises update now to the latest 1.x version which will prompt you before self-updating to 2.x.

then I got this

[InvalidArgumentException]
Could not find a version of package jazmy/jaz-form-builder matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability.

Please advise me what to do?

Grid/column support

Hi there! I am using your package for a project in Laravel that needs formbuilder and I want forms that have 2 columns I found how to do it here kevinchappell/formBuilder#859 and I try it in the formbuilder demo https://formbuilder.online and it works attached capture:
1

see the capture of the html it put the class row-1 col-md-6 inside div class
2

but in your demo with laravel http://demoform.jazmy.com/ I see that it doesn't work and I think it's because of the following:
3

it put the class row-1 col-md-6 inside the input not inside div class as I think should be for work....don't you think?

How can I make the html look the same as formbuilder.online demo and can work 2 columns/grid? Or do you have a better solution to apply columns/grid to forms?

Regards

File upload in public directory

Files are being saved in the public folder of Laravel which is a security vulnerability. Meaning anyone else can access those files if they have the URL of that file because it's publicly accessible to everyone.
So files must be saved in the private folder "storage/app/private".

having multiple inputs (text fields) on a line

First of all, thanks for the great package! I just started working on a project that uses the Laravel MVC that successfully incorporated your form-builder package. I am new to Laravel and to this form-builder. We have noticed that the current form-builder is only allowing one textfield in a line. Is there any way we could customize this to have multiple textfield in a line? For example, could we have a functionality to add a div wrapper? I would really appreciate if you could give any clues or directions.

Route [formbuilder::forms.index] not defined.

Route [formbuilder::forms.index] not defined. (View: /home//lara/resources/views/Admin/component/sidebar.blade.php) (View: /home//lara/resources/views/Admin/component/sidebar.blade.php) (View: /home/******/lara/resources/views/Admin/component/sidebar.blade.php)

i copied project from server to server and make

php artisan config:cache

i got this error

Custom fields issue

I am trying to create custom field called first name, like
field is like below
{
label: "First Name",
type: "firstname",
subtype: "text",
icon: 'โœŽ'
}

and the template is like below

firstname: function(fieldData) {
return {
field: '<input id="'+fieldData.name+'" name="[FirstName]"type="text" readonly>',
}
}
it is creating the form but while submitting i get the issue.

image

please let me know what is the solution

Blank Forms (Javascript Disabled)

If a user disables Javascript in the browser, they can still submit a form.

Head to:
resources > views > vendor > formbuilder > render > index.blade.php

Replace the Submit button with the following that shows a friendly message:

<noscript>
		<p>This site is best viewed with Javascript. Please allow javascript to run.</p>
	</noscript>

	<script type="text/javascript">
		$(function(){
			$('#Submit').attr('disabled', false);

			var $input = $('<button id="Submit" type="submit" class="btn btn-primary confirm-form" data-form="submitForm"> <i class="fa fa-submit"></i> Submit Form </button>');
			$input.appendTo($("#formSubmit"));

			$('#Submit').attr('data-message', "Submit your entry for '{{ $form->name }}'?");
		});
</script>

The function adds the Submit button for those who have Javascript enabled on their browser otherwise displays the message.

Form validation bug

The form validation process is only done through the browser and not the backend.
Assuming that an input is required a user can simply change the delete the required attributes throughout the browsers developers tool. This way there will be no validation left and the form can be submitted without the need of filling that input!

Edit Submissions

Would it be possible for the owner of a form to edit submissions to that form?

Thanks for the awesome integration!

General Error: 3780

Here is the full error:

SQLSTATE[HY000]: General error: 3780 Referencing column 'user_id' and referenced column 'id' in foreign key constraint 'forms_user_id_foreign' are incompatible. (SQL: alter table `forms` add constraint `forms_user_id_foreign
` foreign key (`user_id`) references `users` (`id`) on delete CASCADE)

Laravel Version: 5.8.27

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.