How do I retrieve saved checkbox values from a field using the FormAPI?
The form/node saves successfully, and when I look in the DB, the data was successively saved in the 'field_data_field_test' table, but I can't figure out how to pull that back out and apply the 'checked' status using #default_value.
$form['field_test']['und']['#default_value'] = $How_Can_I_Get_This_Data_From_DB
Is there a function I can use to retrieve checked values for a given field within a given node? I'm trying to avoid direct queries. :)
Edit:
Ended up using
function _get_review_site_defaults() {
$query = new EntityFieldQuery;
global $user;
$result = $query
->entityCondition('entity_type', 'node', '=')
->entityCondition('bundle', 'field_test', '=')
->propertyCondition('uid', $user->uid, '=')
->propertyCondition('status', 1)
->execute();
if (count($result) == 0) {
$defaults = array(1);
} else {
$entities = entity_load('node', array_keys($result['node']));
foreach ($entities as $key => $value) {
if ($value->field_default_field_test[$value->language][0]['value'] == 'Yes') {
$defaults[] = $value->nid;
}
}
}
return $defaults;
}