很难弄清楚如何获取返回的orm对象并将其转换为辅助器的可用数组FORM :: select
$this->template->content = View::factory('form')
->bind('errors', $errors)
->bind('categories', $categories);
$categories = ORM::factory('category');
$categories->order_by('category');
$categories = $categories->find_all();
在表单视图中我有
<tr>
<td><?php echo Form::label('category', 'Category'); ?></td>
<td><?php echo Form::select('category', $categories, $category); ?></td>
</tr>
如何将返回的对象数组$ categories转换为属性数组$ categories
答案 0 :(得分:1)
as_array()是为你做的伎俩。只需使用这一行。
$categories = $categories->find_all()->as_array('id', 'category_label');