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.
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
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community