In my action controller I have:
$user_groups = UserGroup::find(array('columns' => 'id,label'));
$form = new ProductReviewForm($user_groups);
In the form initialize I have:
public function initialize($user_groups) {
$user_groups_array = $user_groups->toArray();
$user_groups_name = array_column($user_groups_array,'id');
$user_groups_label = array_column($user_groups_array, 'label');
$user_group_options = array_combine($user_groups_name, $user_groups_label);
$user_group_element = new \Phalcon\Forms\Element\Select("User Group", $user_group_options);
$user_group_element->setLabel("<label for='User Group' >User Group: </label>");
}
My question? Is there a way to do transform a resultset into an \Phalcon\Forms\Element\Select in less lines?