Hello Guys, I have a form that i used array name.
ei. name[]
this is my code for input form
{{ Form::open(array('url' => 'create')) }}
<TR>
<TD><INPUT type="checkbox" name="chk[]"/></TD>
<TD class="rating">
{{ Form::text('core_values[]', Input::old('core_values[]'), array('placeholder' => 'Criteria Here')) }}</TD>
<TD>
{{ Form::textarea('behavioral[]', Input::old('behavioral[]'), array('placeholder' => 'Description Here', 'cols' => '75', 'rows' => '4')) }}
</TD>
<td class="rating">
{{ Form::text('rating[]', Input::old('rating[]'), array('placeholder' => 'Percentage')) }}</td>
</TR>
</TABLE>
</br>
{{ Form::submit('Submit!', array('class' => 'pull-right btn-warning')) }}
{{ Form::close() }}
and this is my controler code
class SaveController extends BaseController {
public function saveData()
{
$input = Input::all();
for ($idx = 0; $idx < count(Input::get('core_values')); $idx++)
{
$values = new question;
$values->core_values = $input['core_values'][$idx];
$values->behavioral = $input['behavioral'][$idx];
$values->rating = $input['rating'][$idx];
$values->save();
}
// redirect
Session::flash('message', 'Added!');
return Redirect::to('evaluation');
}
}
my problem is, when i add 2 rows into database, only 1 rows added. whats wrong with my codes? iam not good in laravel. help me guys, thanks in advance. your help appreciated