2017 © Pedro Peláez
 

library formkit

A combined back- and front-end package to manage data-submissions and forms in Laravel

image

thehiredgun/formkit

A combined back- and front-end package to manage data-submissions and forms in Laravel

  • Tuesday, November 21, 2017
  • by thehiredgun
  • Repository
  • 0 Watchers
  • 0 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 24 Versions
  • 0 % Grown

The README.md

formkit

A nice bit of kit to help manage form-submissions in Laravel, (*1)

Introduction

FormKit is a two-part package: - FormKit\SubmissionKit dramatically streamlines the work you have to do on the back-end to manage data-submissions and forms - FormKit\TemplateKit dramatically reduces the amount of front-end templating you have to do to build nice-looking forms using Blade & Bootstrap - Together, a developer can get rapidly build out comprehensive solutions to manage all different kinds of data, then tweak on an as-needed basis, (*2)

Installation

Recommended installation is via Composer:, (*3)

composer require thehiredgun/formkit, (*4)

or, add this to your composer.json:, (*5)

"require": {
    ...,
    "thehiredgun/formkit": "^1.0",
    ...
}

SubmissionKit Quick-Start

For traditional Web Application use:

We're going to use a single(!) controller method to manage getting a form and handling a form-submission: In routes/web.php:, (*6)

Route::match(['get', 'post'], '/books/{book}/edit', 'BookController@form');
Route::match(['get', 'post'], '/books/add', 'BookController@form');

Then, in app/Http/Controllers/BookController.php:, (*7)

...
use App\Models\Eloquent\Book;
use Illuminate\Http\Request;
use TheHiredGun\FormKit\SubmissionKit\SubmissionKit;
...
    public function form(Request $request, Book $book = null)
    {
        // define your rules for the form.
        // multi-dimensional array is the preferred style, but you can use an array of strings, as well
        $rules = [
            'title' => [
                'required',
                'string',
            ],
            'author' => [
                'required',
                'string',
            ],
            'published_on' => [
                'required',
                'date_format:Y-m-d',
            ],
        ];
        $form = new SubmissionKit($request, $rules);
        // if the form has been submitted
        if ($request->isMethod('post')) {
            $form->validate();              // validate the form
            $form->setProperties($book);    // set the properties on the $book where the values are valid
            if ($form->isValid()) {
                $book->save();

                return redirect()->route('books');
            }
        }

        return view('books.form', [
            'book'   => $book,
            'errors' => $submissionKit->getErrors(),
        ]);
    }

SubmissionKit For RESTful API usage:

Here we'll use the SubmissionKit in two separate methods: one for POST, and one for PUT In routes/api.php:, (*8)

Route::post('/books', 'BookController@post');
Route::put('/books/{book}', 'BookController@put');

And the BookController:, (*9)

...
    public function post(Request $request)
    {
        $rules = [
            'title' => [
                'required',
                'string',
            ],
            'author' => [
                'required',
                'string',
            ],
            'published_on' => [
                'required',
                'date_format:Y-m-d',
            ],
        ];
        $form = new SubmissionKit($request, $rules);
        $form->validate();              // validate the form
        $form->setProperties(new Book());    // set the properties on the $book where the values are valid
        if ($form->isValid()) {
            $book->save();

            return response($book, 201);
        }

        return response([
            'errors' => $submissionKit->getErrors(),
        ], 400);
    }

    public function put(Request $request, Book $book)
    {
        $rules = [
            'title' => [
                'required',
                'string',
            ],
            'author' => [
                'required',
                'string',
            ],
            'published_on' => [
                'required',
                'date_format:Y-m-d',
            ],
        ];
        $form = new SubmissionKit($request, $rules);
        $form->validate();              // validate the form
        $form->setProperties($book);    // set the properties on the $book where the values are valid
        if ($form->isValid()) {
            $book->save();

            return response(200);
        }

        return response([
            'errors' => $submissionKit->getErrors(),
        ], 400);
    }

The Versions

21/11 2017

dev-master

9999999-dev

A combined back- and front-end package to manage data-submissions and forms in Laravel

  Sources   Download

MIT

The Requires

 

laravel middleware frontend library form bootstrap validator validation backend forms

21/11 2017

v0.8.0

0.8.0.0

A combined back- and front-end package to manage data-submissions and forms in Laravel

  Sources   Download

MIT

The Requires

 

laravel middleware frontend library form bootstrap validator validation backend forms

17/11 2017

v0.7.1

0.7.1.0

A combined back- and front-end package to manage data-submissions and forms in Laravel

  Sources   Download

MIT

The Requires

 

laravel middleware frontend library form bootstrap validator validation backend forms

11/11 2017

v0.7.0

0.7.0.0

A combined back- and front-end package to manage data-submissions and forms in Laravel

  Sources   Download

MIT

The Requires

 

laravel middleware frontend library form bootstrap validator validation backend forms

11/11 2017

dev-add-methods-and-documentation

dev-add-methods-and-documentation

A combined back- and front-end package to manage data-submissions and forms in Laravel

  Sources   Download

MIT

The Requires

 

laravel middleware frontend library form bootstrap validator validation backend forms

10/11 2017

dev-version-one

dev-version-one

  Sources   Download

The Requires

 

03/10 2017

v0.6.0

0.6.0.0

  Sources   Download

The Requires

 

28/07 2017

v0.5.0

0.5.0.0

  Sources   Download

The Requires

 

04/07 2017

dev-create-template-kit

dev-create-template-kit

  Sources   Download

The Requires

 

04/07 2017

v0.4.0

0.4.0.0

  Sources   Download

The Requires

 

16/06 2017

dev-issue#5

dev-issue#5

  Sources   Download

The Requires

 

16/06 2017

dev-issue#4

dev-issue#4

  Sources   Download

The Requires

 

16/06 2017

v0.3.0

0.3.0.0

  Sources   Download

The Requires

 

16/06 2017

v0.2.1

0.2.1.0

  Sources   Download

The Requires

 

16/06 2017

dev-issue/3

dev-issue/3

  Sources   Download

The Requires

 

15/06 2017

dev-issue/2

dev-issue/2

  Sources   Download

The Requires

 

15/06 2017

v0.2.0

0.2.0.0

  Sources   Download

The Requires

 

15/06 2017

dev-issue/1

dev-issue/1

  Sources   Download

The Requires

 

15/06 2017

v0.1.5

0.1.5.0

  Sources   Download

The Requires

 

15/06 2017

v0.1.4

0.1.4.0

  Sources   Download

The Requires

 

15/06 2017

v0.1.3

0.1.3.0

  Sources   Download

The Requires

 

15/06 2017

v0.1.2

0.1.2.0

  Sources   Download

The Requires

 

15/06 2017

v0.1.1

0.1.1.0

  Sources   Download

The Requires

 

15/06 2017

v0.1.0

0.1.0.0

  Sources   Download

The Requires