1. Go to this page and download the library: Download bllim/laravalid library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
'aliases' => array(
...
'HTML' => Collective\Html\HtmlFacade::class, // if not exists add for html too
'Form' => Bllim\Laravalid\Facade::class,
),
$rules = ['name' => 'l' => 'foo/bar', 'method' => 'put'), $rules);
Form::text('name');
Form::text('email');
Form::text('birthdate');
Form::close(); // don't forget to close form, it reset validation rules
// in controller or route
$rules = ['name' => 'lso use without giving form name Form::setValidation($rules) because there is just one.
// in view
Form::open(array('url' => 'foo/bar', 'method' => 'put', 'name' => 'firstForm'), $rules);
// some form inputs
Form::close();
$rules = ['age' => 'numeric|max'];
class UserController extends Controller {
static $createValidations = ['name' => 'ons);
return View::make('user.create');
}
public function postCreate()
{
$inputs = Input::only(array_keys(static::$createValidations));
$validator = Validator::make($inputs, static::$createValidations);
if ($validator->fails())
{
// actually withErrors is not really necessary because we already show errors at client side for normal users
return Redirect::back()->withErrors($validator);
}
// try to create user
return Redirect::back()->with('success', 'User is created successfully');
}
}
Form::converter()->rule()->extend('someotherrule', function($parsedRule, $attribute, $type){
// some code
return ['data-rule-someotherrule' => 'blablabla'];
});
Form::converter()->message()->extend('someotherrule', function($parsedRule, $attribute, $type){
// some code
return ['data-message-someotherrule' => 'Some other message'];
});
Form::converter()->route()->extend('someotherrule', function($name, $parameters){
// some code
return ['valid' => false, 'messages' => 'Seriously dude, what kind of input is this?'];
});
bash
$ php artisan vendor:publish
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.