0

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.

2
  • Just throwing this out there, there is a module that already does this feeds + feeds xls does what you're trying to do.
    – No Sssweat
    Commented Dec 22, 2015 at 20:00
  • I also try to find the same functionality but not succeeded.
    – WaQaR Ali
    Commented Jan 13, 2016 at 12:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.