-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Hi @barryvdh,
First of all, thank you very much for the package!, it's helping me a lot with a new project.
Like de title says, i need some guide to figure out why i cant get array validations errors in twig.
I can see those errors in blade ViewErrorBag, but not in twig.
Here a simple example:
web.php
Route::any('/test', 'FormController@demo');FormController.php
public function demo(Request $request){
$form = $this->createFormBuilder(null)
->add('name', TextType::class)
->add('file', FileType::class, [
'multiple' => true
])
->add('save', SubmitType::class, ['label' => 'Save'])
->getForm();
$form->handleRequest($request);
if ($form->isSubmitted()) {
$this->validateForm($form, $request, [
'name' => 'required|min:10',
"file" => "required|max:2",
"file.*" => "file|max:1024|mimes:png"//Can't get this validations errors in twig
]);
dd($form->getData());
}
return view('formularios.form_test', ['form' => $form->createView()]);
}form_test.blade.php
...
<div class="container">
<div class="row">
<div class="col-md-12">
@formStart($form, [ 'attr' => ['autocomplete' => 'off']])
@formWidget($form)
@formEnd($form)
</div>
</div>
<div class="row">
<div class="col-md-12">
@if ($errors->any()) //to check in ViewErrorBag
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
</div>
</div>
</div>
...And, for example if I add three jpg files (the validation only accept png), this is what i get:
As you can see, twig only shows the 'file' validation, but not the 'file.*' one.
Any help would be appreciated.
Regards,
Leo
Metadata
Metadata
Assignees
Labels
No labels
