Reputation: 897
I have the following HTML code in a twig view file
<input type="text"
name="myArray[{{ nthRow }}][description][{{ language.language_id }}][name]"
value="{{ myArray.description.language_id.name }}"
class="form-control" />
this is the print_r of the array which is being sent to the twig file
Array (
[0] => Array (
[var1] => safds
[var2] => 0
[var3] => 1000
[description] => Array ( [1] => Array ( [name] => bla bla ) )
)
)
how can I reach the name element of the array??
Upvotes: 0
Views: 106
Reputation: 897
I have solved it, it should be like this,
<input type="text"
name="myArray[{{ nthRow }}][description][{{ language.language_id }}][name]"
value="{{ myArray.description[language.language_id].name }}"
class="form-control"
/>
Upvotes: 0
Reputation: 767
How about myArray[nthRow].description[language.language_id].name
so the twig code may look like this
<input type="text"
name="myArray[{{ nthRow }}][description][{{ language.language_id }}][name]"
value="{{ myArray[nthRow].description[language.language_id].name }}"
class="form-control" />
Upvotes: 1