What happened?
Thinking that the {% namespace %} tag should accept 0 as a value, and it currently doesn't. Probably to do with a falsey check, but I can't figure out how that works, sorry!
{% set items = ['first', 'second'] %}
{% for item in items %}
{% namespace loop.index0 %}
{{ tag('input', {
name: item,
}) }}
{% endnamespace %}
{% endfor %}
// Produces
<input name="first">
<input name="1[second]">
// Expected
<input name="0[first]">
<input name="1[second]">
In reality, this would be surrounded by fields and the field handle, but in this reduced example, you can't have multiple {% namespace %} tags, so in a real-world use-case you'd produce:
// Expected
<input name="fields[myField][0][first]">
<input name="fields[myField][1][second]">
My use-case here is that the value for a field is an array, and I'd like to keep things simple by using an array syntax, rather than new1 or similar like Matrix does.
Craft CMS version
4.5.9
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
What happened?
Thinking that the
{% namespace %}tag should accept0as a value, and it currently doesn't. Probably to do with a falsey check, but I can't figure out how that works, sorry!{% set items = ['first', 'second'] %} {% for item in items %} {% namespace loop.index0 %} {{ tag('input', { name: item, }) }} {% endnamespace %} {% endfor %} // Produces <input name="first"> <input name="1[second]"> // Expected <input name="0[first]"> <input name="1[second]">In reality, this would be surrounded by
fieldsand the field handle, but in this reduced example, you can't have multiple{% namespace %}tags, so in a real-world use-case you'd produce:My use-case here is that the value for a field is an array, and I'd like to keep things simple by using an array syntax, rather than
new1or similar like Matrix does.Craft CMS version
4.5.9
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions