Home › Forums › Quform WordPress › How to save a form forlater
- This topic has 6 replies, 2 voices, and was last updated 1 year, 1 month ago by
Ally.
- AuthorPosts
- August 3, 2023 at 9:02 am #35826
adaka
ParticipantHi,
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
August 4, 2023 at 9:48 am #35830Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
August 4, 2023 at 10:12 am #35832adaka
ParticipantHi,
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.August 4, 2023 at 10:45 am #35836Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
August 4, 2023 at 1:03 pm #35837adaka
ParticipantThanks 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.August 7, 2023 at 10:54 am #35852Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
August 8, 2023 at 10:17 am #35857Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.