L
L
Lucius Mooning2017-10-05 07:43:44
Laravel
Lucius Mooning, 2017-10-05 07:43:44

How to competently organize validation, saving and displaying 30+ fields on a page?

Good afternoon!
I am writing a project in Laravel.
Tell me, please, how to properly organize validation, saving and displaying 30+ fields on a page?
The fields are in text format and have the same validation rules.
It seems to me that there is a solution - to do it not manually, but in the form of a cycle, or in some other way, so as not to prescribe all the fields.
For example, I don't like this solution:
Validation in the controller
public function update(Request $request, $id)
{
$this->validate($request, [
'id' => 'required|exists:forms,id',
' name' => 'required|min:6',
'name1' => 'required|min:6',
'name2' => 'required|min:6',
'name3'
'name4' => 'required|min:6',
]);
}
Mapping to template:
Name
{!! CollectiveForm::textarea('name', null, ['class' => 'form-control ', 'rows' => "3"]) !!}
Name1
{!! CollectiveForm::textarea('name1', null, ['class' => 'form-control ', 'rows' => "3"]) !!}
Name2
{!! CollectiveForm::textarea('name2', null, ['class' => 'form-control ', 'rows' => "3"]) !!}
I'm looking for a more adequate way.
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question