In Laravel:$validate = Validator::make( $request->all(), ['test.*'=> 'max:10']);But in PHP code the trick doesn't work" />

HTML form array validation in Laravel 5.2

php laravel-5

53 просмотра

1 ответ

549 Репутация автора

How to validate an array coming from HTML form?

ex:

<input type="text" name="test" value="[value1,value2,value3]">

In Laravel:

$validate = Validator::make(
    $request->all(),
    ['test.*'=> 'max:10']
);

But in PHP code the trick doesn't work

Автор: ِAllloush Источник Размещён: 18.07.2016 07:02

Ответы (1)


0 плюса

388 Репутация автора

In laravel you could try this:

Controller -

public function someAction(){

   $validator = Validator::make($request->all(), 

   [
      'test'  => 'required|max:10',
      'test2' => 'required|max:2'
      ]
  );

  if($validator-fails()){

      return Somthing;

    }else{

       // Pass the form input fields values for use
        $test  = Input::get('test');
        $test2 = Input::get('test2');
      }

}

Or try this method given here

Автор: George Udosen Размещён: 23.09.2016 07:31
Вопросы из категории :
32x32