Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

peter's avatar

Submitting multiple rows with a single form entry.

Hi, I am just a week old to Laravel. I have a page passing multiple group of elements to the same method in my controller. More explanation: Say you want to do a bulk submission into a database table using a single form entry. I know the "input::all()" grabs all the data elements, but since you can't tell the specifics at run time, is there any way of handling that?

0 likes
1 reply
pmall's avatar
pmall
Best Answer
Level 56

You have to structure the names of your fields in your html. Example : 'entities[index][name]' with index being the same value for all the fields of the same entity. So in your controller action you get an array of values ['entities' => [0 => ['name' => 'name of entity 1'], 1 => ['name' => 'name of entity 2'], ...]].

Then you can loop through your entities in your controller action :

foreach ($request->entities as $entity) {

    Entity::create($entity);

}
2 likes

Please or to participate in this conversation.