I am creating form using the following code:
In the create.blade.php file
{!! Form::open(['route'=>'orcamentos.store']) !!}
{!! Form::text('descricao', null, ['class'=>'form-control', 'autofocus']) !!}
{!! Form::text('produto[]', null, ['class'=>'form-control']) !!}
{!! Form::text('produto[]', null, ['class'=>'form-control']) !!}
// Esse campo produto pode se repetir inúmeras vezes em tela
{!! Form::submit('Salvar', ['class'=>'btn btn-primary']) !!}
Notice that I can have 'N' input 'product'.
In my controller I have this:
public function store(OrcamentoRequest $request){...}
And in the OrcamentoRequest class I want to validate the mandatory fields, does anyone know how I can do this?
Within function rules
I have already made some attempts based on the searches made on the internet, but I did not succeed.
Below are some unsuccessful attempts:
TRY 1:
$rules = [
'descricao' => 'required',
'produto.*' => 'required',
];
TRY 2:
foreach($this->request->get('produto') as $key => $val){
$rules['produto.'.$key] = 'required';
}
I also found something in the documentation itself. link here but nothing worked.
The error you are giving is this:
ErrorException in helpers.php line 531:
htmlentities() expects parameter 1 to be string, array given
Has anyone gone through this before? Or do you know the answer?