Support the ongoing development of Laravel.io →
Input Blade Forms

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[&quot;$dues_type_id&quot;]" 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!

Last updated 2 years ago.
0

Replace with double quotes and you should be fine:

{{ Form::text( "dt[$dues_type_id]", $display_amount) }}
Last updated 2 years ago.
0

What about

{{ Form::text( 'dt['.$dues_type_id.']', $display_amount) }}
Last updated 2 years ago.
0

Both of the above work equally -- thanks! (I could only mark one as the solution, so I clicked on the first.)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

zocios zocios Joined 28 May 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.