I´m trying to create a dynamic list of checkboxes. I get the list of checkboxes by selecting them from my database. But now i get the error that i cannot use this list because of type ResultSet and not Array. How can I do this? Heres my code(I´m totally aware that its not good code)
my function for fetching and passing to the view
public function indexAction(){
$adapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
$input = new SearchModel($adapter);
$rowset = $input->getName();
$form = new SearchForm($rowset['name']);
$model = new ViewModel(array('form' => $form, 'input' => $rowset));
$model->setTemplate('search/index');
return $model;
}
My model action
public function getName(){
$sql = "SELECT * FROM benutzer";
$rowset = $this->adapter->query($sql, \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
return $rowset;
}
And my Form
public function __construct($name = null){
$this->add(array(
'type' => 'Zend\Form\Element\MultiCheckbox',
'name' => 'name',
'options' => array(
'label' => 'Sportart',
'value_options' => $name,
),
));
}