I have two fields in question, field_in and field_cm. The user is presented with one or the other (based on roles rule only one filed is shown, the other one is hidden). The form is created via admin - a custom content type form.
Problem: trying to populate the hidden field based on the user input in the visible field - the value is not saving to the db.
I added a custom submit function to the normal node_form_submit to handle the calculation, but it does not seem to add data - I do not see anything in the db. What am I doing wrong?
<?php
/**
* Implements hook_form().
*/
function my_module_form_alter(&$form, &$form_state, $form_id) {
if( $form_id == 'reading_node_form') {
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Add Reading'),
'#weight' => 50,
'#ajax' => array(
'wrapper' => 'reading-node-form',
'callback' => 'my_module_callback',
'clear' => TRUE,
'effect' => 'fade'
),
'#submit' => array('calculate_values_submit','node_form_submit'),
);
}
return $form;
}
function my_module_callback($form, &$form_state) {
$node = new stdClass();
$node->type = 'reading';
return drupal_get_form('node_form', $node);
}
function calculate_values_submit($form_id, &$form_state) {
$form_state['rebuild'] = TRUE;