How to arrange the validation, preservation and display of the 30+ fields on the page?

Good day!

Writing a project in Laravel.

Prompt, pozh-hundred how to arrange the validation, preservation and display of the 30+ fields on the page ?
The fields are in text format and have the same validation rules.

I think there's a solution to do it manually and not in the form of a loop, or something else, not to register all the fields.

For example, here is a solution I don't like:

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' => 'required|min:6',
'name4' => 'required|min:6',

]);
}

Display 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"]) !!}

Looking for a more adequate method.

Thank you.
June 14th 19 at 19:18
1 answer
June 14th 19 at 19:20
Validation on frontend. Why 30+ fields on one page?
It is clear.

30+ in one table.

The page has tabs, each of which has approximately the same number of fields. - minerva_Welch commented on June 14th 19 at 19:23
I think there's a solution to do it manually and not in the form of a loop, or something else, not to register all the fields.

For example, here is a solution I don't like:

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' => 'required|min:6',
'name4' => 'required|min:6',

]);
}

Display 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"]) !!}

Looking for a more adequate method. - minerva_Welch commented on June 14th 19 at 19:26

Find more questions by tags Laravel