从数组中渲染单个数据
Rendering single data from an array
{{dump(states)}} 这个 returns
FormView {#5921 ▼
+vars: array:33 [▼
"value" => []
"attr" => []
"form" => FormView {#5921}
"id" => "States"
"name" => "States"
"full_name" => "States"
"disabled" => false
"compound" => false
"method" => "POST"
"action" => ""
"preferred_choices" => []
"choices" => array:41 [▶]
]
+parent: FormView {#5618 ▶}
+children: []
-rendered: false
-methodRendered: false
}
我想显示选择选项的状态 35.how 以从有 41 个选择的数组中获得单一选择?
您可以使用 . 或 [] 语法访问 twig 中的数组成员。
因此你选择数组的第 35 个选项可以在 twig 中呈现如下:
{{ states.vars.choices[34] }}
有关如何访问 twig 中的数组成员的更多信息,请查看 this article from knpuniversity
{{dump(states)}} 这个 returns
FormView {#5921 ▼
+vars: array:33 [▼
"value" => []
"attr" => []
"form" => FormView {#5921}
"id" => "States"
"name" => "States"
"full_name" => "States"
"disabled" => false
"compound" => false
"method" => "POST"
"action" => ""
"preferred_choices" => []
"choices" => array:41 [▶]
]
+parent: FormView {#5618 ▶}
+children: []
-rendered: false
-methodRendered: false
}
我想显示选择选项的状态 35.how 以从有 41 个选择的数组中获得单一选择?
您可以使用 . 或 [] 语法访问 twig 中的数组成员。
因此你选择数组的第 35 个选项可以在 twig 中呈现如下:
{{ states.vars.choices[34] }}
有关如何访问 twig 中的数组成员的更多信息,请查看 this article from knpuniversity