I have a form which loops through an array to create the form elements, so the name of each input element must be an array element. It's easy to do this with plain old PHP:
<input type="text" name="dt[<?php echo $dues_type_id ?>]" ... />
where $dt is the array whose indices are dues types ids.
No matter what combination of quotes and curly braces I use, I cannot make this work using Blade. For example, this does not cause an error message, but it doesn't work:
{{ Form::text( 'dt[{{{ $dues_type_id }}}]', $display_amount) }}
The source code for the Blade construction is this:
<input name="dt["$dues_type_id"]" type="text">
Of course, I could just code this in PHP, but I already have all of my CSS formatting set up with Blade, and besides -- this SHOULD be possible, and I'm frustrated because I can't figure out how to do it. I'm sure I'm missing something easy... Thanks!
Replace with double quotes and you should be fine:
{{ Form::text( "dt[$dues_type_id]", $display_amount) }}
What about
{{ Form::text( 'dt['.$dues_type_id.']', $display_amount) }}
Both of the above work equally -- thanks! (I could only mark one as the solution, so I clicked on the first.)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community