I'm attempting to populate default values for a form from a database table. I've created the database select statements as shown below and want to assign the field values that are retrieved to different form attributes for the form field. I believe the db_select statement I wrote is at least syntactically correct, but I can't seem to figure out what the correct format/syntax is for the final step in assigning the db_select results to the form fields. I've only attempted the #default_value in the code below.
In the case below, I get the error message:
Notice: Undefined index: value_default in v01_fields() (line 60 [which is the #default_value line]
/** For the table v01fielddata, return three fields based on the submitted primary key (fieldid), v01price. */
function v01_v01fielddata_fetch () {
$query = db_select('v01fielddata')
->condition('fieldid', 'v01price')
->fields('v01fielddata', array('title_default', 'desc_default', 'value_default'));
$result = $query->execute();
variable_set('v01price_result', $result);
}
/**
* Input Form
*/
function v01_fields ($form, &$form_submit) {
$result = variable_get('v01price_result', array());
$form['v01_price'] = array (
'#title' => t('Vehicle purchase price'),
'#type' => 'textfield',
'#default_value' => $result['value_default'],