How to save a form forlater

Home Forums Quform WordPress How to save a form forlater

This topic is: not resolved
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #35826
    adaka
    Participant

    Hi,

    We currently have a multi-step form on our site. This form has 14 file-type fields. I’ve done the same as on https://support.themecatcher.net/quform-wordpress-v2/guides/customization/saving-form-data-for-later, although I’ve modified it to save in the database and not in the cookies. However, with this manipulation, the files aren’t saved, but all the other fields are. Do you have any idea how to save the files?

    Thanks

    #35830
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #35832
    adaka
    Participant

    Hi,

    Thank you for your reply, however I don’t save in the cookies as in the documentation but in the database in a personal encrypted table.
    However, I have another problem, much more serious at the moment, I want to display the form I’ve already submitted but the information isn’t coming back correctly, in fact the classic fields are coming back but there are problems with the files and checkboxes, can you help me? Here’s a code snippet:

    add_action(‘quform_pre_display_’ . $form_id, function (Quform_Form $form) {
    //We get last send value
    global $currentForm;
    if ($currentForm && is_array($currentForm)) {
    foreach ($currentForm as $res) {
    $form->setValue(
    “quform_” . $res->form_id . “_” . $res->element_id,
    is_serialized($res->value) ? unserialize(quform_set_value_from_storage($res->value)) : quform_set_value_from_storage($res->value)
    );
    if ($form->getElement(“quform_” . $res->form_id . “_” . $res->element_id) instanceof Quform_Element_File) {
    $values = [];
    var_dump(unserialize(quform_set_value_from_storage($res->value)));
    foreach (unserialize(quform_set_value_from_storage($res->value)) as $key => $arr) {
    foreach ($arr as $k => $a) {
    $values[$k][] = $a;
    }
    $values[“error”][$key] = 0;
    }
    $_FILES[“quform_” . $res->form_id . “_” . $res->element_id] = $values;
    }
    }
    } else {
    global $wpdb;
    $form_id = get_field(‘form_used_id’, ‘option’) ? get_field(‘form_used_id’, ‘option’) : 1;
    $user_id = get_current_user_id(); // Vous pouvez obtenir l’ID de l’utilisateur enregistré

    // Vérifier si une ligne avec le même user_id existe déjà
    $existing_row = $wpdb->get_row(“SELECT * FROM ” .$wpdb->prefix .”users_save_registration_step WHERE user_id = ” .$user_id .” AND form_id = ” .$form_id);

    if ($existing_row) {
    $existing_row->form_data = quform_set_value_from_storage($existing_row->form_data);
    parse_str($existing_row->form_data, $values);
    $form->setValues($values);

    }
    }
    });

    Attachments:
    You must be logged in to view attached files.
    #35836
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #35837
    adaka
    Participant

    Thanks Ally,

    I now have the name of the file but when I do next it tells me that the field is mandatory, what can I do?

    Attachments:
    You must be logged in to view attached files.
    #35852
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #35857
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy