Giter VIP home page Giter VIP logo

groform's Introduction

Groform

A Laravel package to create forms easily with in build validation.

Installation


By default, Composer pulls in packages from Packagist so you’ll have to make a slight adjustment to your project composer.json file. Open the file and update include the following array somewhere in the object:

"repositories": [
    {
    "type": "vcs",
    "url": "https://github.com/sauruz/groform"
    }
]

Now composer will also look into this repository for any installable package. Execute the following command to install the package:

composer require sauruz/groform

Now, open the config/app.php file and scroll down to the providers array. In that array, there should be a section for the package service providers. Add the following line of code in that section:

/*
* Package Service Providers...
*/
Sauruz\Groform\Providers\GroformProvider::class

Publish files


Groform standard ships with 1 example contact and input fields. You can edit them the way you like.

Publish the forms

php artisan vendor:publish --tag=groform-forms

Publish the views

php artisan vendor:publish --tag=groform-views

The example contact form will be added to resources/groforms/. Remember, groforms always have the extension groform.php. The input views will be added to resources/views/groform/.

Use Forms


In the example contact.groform.php you can find all the configurations. To use the example contact form simply add this to a view:

<x-groform form="contact"/>

to validate the contact form you can do this in your controller:

use Sauruz\Groform\Groform;
use Illuminate\Http\Request;

class FormController extends Controller
{
    public function store(Request $request) {
        $request->validate(Groform::validationRules('contact'));
        ...
    }
}

Default values

You can add default values by feeding a model to the form like this:

<x-groform form="contact" :model="$contactModel"/>

groform's People

Contributors

sauruz avatar

Watchers

 avatar

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.