I'm altering a form made through admin panel using below code to copy text from first textarea to second. This is done by clicking on 'Copy' button. Frontend works well as expected.
However when I submit the form using default submit button, values in textareas are not added to database. Therefore if I go to webform results from admin panel, I can't see any of the values.
Do I need to add anything to custom submit handler for this?
Thanks
function fence_quote_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'webform_client_form_1'){
$form['input'] = array(
'#type' => 'textarea',
'#title' => t('Input text'),
'#prefix' => '<div id="in-text">',
'#attributes' => array(
'placeholder' => t('Enter some text here... '),
),
'#suffix' => '</div>',
);
$form['buttons']['fence_quote'] = array(
'#type' => 'button',
'#value' => t('Copy'),
'#ajax' => array(
'callback' => 'fence_quote_form_callback',
'wrapper' => 'out-text',
),
);
$form['output'] = array(
'#type' => 'textarea',
'#title' => t('Output text:'),
'#prefix' => '<div id="out-text">',
'#value' => '',
'#attributes' => array(
'placeholder' => t('Your text will appear here...'),
),
'#suffix' => '</div>',
);
$form['#validate'][] = 'mymodule_someform_custom_validation';
$form['#submit'][] = 'my_custom_submit_function_submit';
}
}
function fence_quote_form_callback($form, &$form_state) {
$form['output']['#value'] = $form_state['values']['input'];
return $form['output'];
}
function my_custom_submit_function_submit($form, &$form_state) {
}