I would like to check the array that was POSTed in the Validater of FuelPHP.
I sent it with the following source, but the show_errors() display is blank.
Excuse me, please teach me.
<input type="text" name="title[]"value="">
<input type="text" name="title[]"value="">
<input type="text" name="title[]"value="">
// Get input value
Session::set('inputs', Input::all());
$inputs=Session::get('inputs');
// Creating an instance of validation
$validate=Validation::forge();
foreach($inputs['title'] as $key=$value)
{
$validate ->add("title[$key]", "[$value]th title")
->add_rule('trim')//Remove spaces before and after
->add_rule('required')//Required
->add_rule('max_length',50);// Maximum number of characters entered
}
$validate ->run();
// This flash session does not appear on the screen, it is blank
Session::set_flash('error', $validate->show_errors());
$validate->run()
In the case of
we will take the data from POST.
If you want to validate any value from a session, etc.,
$validate->run($inputs)
Let's say
Alternatively, if you want to validate array data arbitrarily
http://fuelphp.jp/docs/1.8/classes/validation/validation.html#extending_validation
You may want to create your own validation
© 2024 OneMinuteCode. All rights reserved.