如何在CakePHP中使用会话值填充选择框 [英] How to populate select box with the session values in CakePHP
问题描述
我在会话中存储了许多员工对象。如何用所有雇员的姓名填充选择框。cakephp我是一个非常陌生的人,所以请向我解释语法。
I have stored many employee objects in session. how to populate the select box with the name of the all employees.i am very new to cakephp so explain me the syntax.
推荐答案
假设您在会话中的雇员对象采用以下格式
array('Employee.id'=>'Employee.name')
在您的视图中包含以下语句的选择框: $ this-> Form-> select('employees',$ employees)
(其中$ employees是一个格式为
Assuming that your employee objects in your session are in the following format
array('Employee.id' => 'Employee.name')
you can populate the selectbox with the following statement in your views: $this->Form->select('employees', $employees)
(where $employees is an array formatted as above).
另请参见 http:/ /book.cakephp.org/view/1430/select 了解有关选择框语法的更多信息。
See also http://book.cakephp.org/view/1430/select for more info on the syntax of the select box.
这篇关于如何在CakePHP中使用会话值填充选择框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!