I'm working on a custom module and I'm adding a form that uses checkboxes. All is fine with using code like:
$form['tags'] = array( '#type' => 'checkboxes', '#options' => array( 88 => 'option1', 100 => 'option 2', 79 => 'etc' ), '#title' => t('Tag this project as...'), );
The problem comes from the fact that I'd like to pull the key and value from the database (a specific taxonomy). I do not want to use an autocomplete, I want to use checkboxes.
Specifically, how do I get the results from the database and format into a proper array for the options array? Also, on the edit version of the form I'm creating, how do I show items that have been "checked" based on their value?
All of the examples I've seen are extremely basic and never show how to do this from a database call. Thanks for reading/answering