To add a new check in Laravel, I did the following:
created a new file called customValidation.php
in app/start/
and then included it in app/start/global.php
and tested it with echo()
, and it worked. Now it loads into the application.
Then I wrote the following code to check for flags in Laravel:
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ class customValidate extends Illuminate\Validation\Validator { public function validateCheckbox($attribute, $value, $parameters) { //if(isset($value)) { return true; } else { return true; } echo "this is the: " . $value; } } /** * Resolvers for Custom Validations */ Validator::resolver(function($translator, $data, $rules, $message){ return new customValidate($translator, $data, $rules, $message); });
However, in my validation rules, I define:
`array('sex'=>'checkbox')`
But that will not work. Nothing has happened. An error does not occur. The application behaves as if it did not perform this function at all. Also, when I repeat something from within the function, nothing gets echoed, another proof that the function is not called at all.
user3077503
source share