2017 © Pedro Peláez
 

library laravel-formvalidation-helper

A helper to easy validate laravel forms.

image

artisaninweb/laravel-formvalidation-helper

A helper to easy validate laravel forms.

  • Thursday, August 7, 2014
  • by artisaninweb
  • Repository
  • 0 Watchers
  • 2 Stars
  • 32 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Laravel form validation helper

A helper to easy validate laravel forms., (*1)

Installation

Add artisaninweb/laravel-formvalidation-helper as requirement to composer.json, (*2)

{
    "require": {
        "artisaninweb/laravel-formvalidation-helper": "0.1.*"
    }
}

Replace 'Illuminate\Html\HtmlServiceProvider' with 'Artisaninweb\FormValidationHelper\ServiceProvider', (*3)

Replace in aliases 'Form' => 'Illuminate\Support\Facades\Form' with 'Form' => 'Artisaninweb\FormValidationHelper\Facades\Form', (*4)

Usage

The parameters to use:, (*5)

required (bool): Make the field required.
rules (string): Specify the rules of the validation.
error-class (string): Add a custom class to the form field on error (optional, default: 'error')., (*6)

Form::text('field-name','field-value',[required' => true, 'rules' => 'required|email', 'error-class' => 'form-error']);

To output the error you can place this in your view.
Default the error wil come from the validator, you can edit this in /app/lang/{lang}/validation.php., (*7)

// Replace the error with you own.
Form::error('field-name','

You can put a custom html error here., (*8)

'); // Only replace the html tags Form::error('field-name','

:message, (*9)

');

Example:, (*10)

echo Form::open(['url' => '/login']);
echo Form::text('email', '', ['required' => true, 'rules' => 'required|email', 'error-class' => 'form-error']);
echo Form::error('email', '<p>This field is required.</p>');
echo Form::password('password', '', ['required' => true, 'rules' => 'required|min:8', 'error-class' => 'form-error']);
echo Form::error('password', '<p>This field is required.</p>');
echo Form::submit('Login');
echo Form::close();

After a form submit you can validate the last submitted form., (*11)

Form::validate(function($postData,$passes,$messages) {
    var_dump($postData);
    var_dump($passes);
    var_dump($messages);
});

TwigBridge

If you are using https://github.com/rcrowe/TwigBridge as TwigBirdge in Laravel (like i do).
You can replace 'TwigBridge\Extension\Laravel\Form' with 'Artisaninweb\FormValidationHelper\Extension\TwigBridgeForm'.
You will find this in app/config/packages/rcrowe/twigbridge/extensions., (*12)

The Versions

07/08 2014

dev-master

9999999-dev

A helper to easy validate laravel forms.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Michael van de Rijt

laravel form helper validate

07/08 2014

0.1

0.1.0.0

A helper to easy validate laravel forms.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Michael van de Rijt

laravel form helper validate