I'm using Drupal 7 for my website. I created custom settings page with custom form in it, but the problem is I don't know proper way to load inserted value from database to my form after saving it, and every time I write something in it, information is written to database, but form is empty. My code looks like this for this:
function registration_pdf_form($form, $form_state) {
$form['registration_body_twoside'] = array(
'#type' => 'text_format',
'#title' => t('Two-sided PDF'),
);
$form['registration_body_threeside'] = array(
'#type' => 'text_format',
'#title' => t('Three-sided PDF'),
);
$form['actions'] = array(
'#type' => 'actions'
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save settings')
);
return $form;
}
function registration_pdf_form_submit($form, $form_state){
$values = array(
'reg_twoside' => $form_state['values']['registration_body_twoside']['value'],
'reg_threeside' => $form_state['values']['registration_body_threeside']['value'],
);
$insert = db_update('pdf_settings')
-> fields(array(
'reg_twoside' => $form_state['values']['registration_body_twoside']['value'],
'reg_threeside' => $form_state['values']['registration_body_threeside']['value'],
))
->execute();
drupal_set_message(t('Settings have been saved'));
}
How do I get values to my fields from database?