I have a text-area with some content inside. I have another form element that is for upload xls file. Now what I want to achieve is, when I click on upload button the xls file content should replace the text-area content.
$form['edit_file'] = array(
'#type' => 'textarea',
'#required' => TRUE,
'#rows' => 20,
'#default_value' => !empty($raw_xml) ? $raw_xml : '',
// '#states' => array(
// 'visible' => array(
// ':input[name ="upload_excel_files_upload_button"]' => array('value' => 'Upload'),
// ),
// ),
);
$form['upload_excel_files'] = array(
'#title' => t('Upload Excel File'),
'#type' => 'managed_file',
'#description' => t('Please upload only .xlsx files.'),
'#size' => 50,
// '#ajax' => array(
// 'callback' => 'replace_existing_xml_callback',
// 'wrapper' => 'replace-existing-xml-div',
// 'method' => 'replace',
// 'effect' => 'fade',
// ),
);
How can I replace "edit_file" form item content by uploaded file?? I can't write this logic in form submit handler because on submit, text-area content get saved into database.
Any help will be highly appreciated. Thanks in advance.