I need to add fields to a node creation/editing form programmatically. More specifically, I need to take already-generated form elements from another form and insert them into the node submission form.
That part isn't what's hanging me up though. My problem is that I can't figure out how to make the database hang onto the values submitted via the new field.
For example, the following code (copypasta'd directly from the API Quickstart page) creates a form element inside the existing node form just fine, but when I enter a value and submit the form, the value is not stored.
function [mymodule]_form_alter(&$form, &$form_state, $form_id) {
$form['foo'] = array(
'#type' => 'textfield',
'#title' => t('bar'),
'#default_value' => t('foo'),
'#size' => 60,
'#maxlength' => 64,
'#description' => t('baz'),
);
}
How do I alter an existing form in such a way that the submitted values 'take,' so to speak?