Support the ongoing development of Laravel.io →
posted 11 years ago
Input Forms

Hi,

I have a form which is populated dynamically for each employee. Each employee has a set of input fields associated (first name, last name, email). When I have 5 employees, I will end up having 5 sets of these fields.

In view, I use blade templating to create the fields:

{{ Form::text("first_name[$index]", $value = $employee_details->first_name,  $attributes = array()) }}

which generates:

<input class="form-control" name="first_name[0]" value="Name" id="first_name[0]" type="text">

In controller, I use the following syntax to retrieve the value:

$employee->first_name = Input::get('first_name')[$i];

This works on php 5.5.3 (development system) and not on PHP 5.3.10 (server).

What is the correct (backward compatible) syntax to fetch the value of the input field in laravel?

Thank you.

Last updated 3 years ago.
0

I don't think you can do it in one line in PHP 5.3.

$first_name = Input::get('first_name');
$employee->first_name = $first_name[$i];

Accessing arrays directly on return values from functions is one of those nifty new features added in PHP 5.4.
http://php.net/manual/en/migration54.new-features.php

Last updated 3 years ago.
0

It worked!

Thank you :)

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

and and Joined 3 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.