php - CakePHP, How to populate a select box from a sql database -
in controller have field
$employee = tableregistry::get('employees'); $allnames = $employee->find()->extract('employee_name'); $this->set('name', $allnames);
works fine, retrieves data want in template
i have code belongs form im trying submit , save database.
<?= $this->form->select('employee', $name, ['escape' => false])?>
which works fine except when submit comes saying wasnt able save database.
i suspect because if change input id type in saves fine. doing wrong?
you should $query = $articles->find('list');
http://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html
chapter :finding key/value pairs¶
Comments
Post a Comment