{{dump(states)}}返回
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。如何从具有41个选择的数组中取出单个选择?
答案 0 :(得分:1)
您可以使用。或 [] 语法访问树枝中的数组成员。
因此,您可以在树枝中以如下方式呈现选择数组的第35个选择:
{{ states.vars.choices[34] }}
有关如何访问树枝中的数组成员的更多信息,请查看this article from knpuniversity