Home › Forums › Quform WordPress › Form misses field from time to time
- This topic has 6 replies, 2 voices, and was last updated 5 years, 3 months ago by Ally.
- AuthorPosts
- December 12, 2018 at 7:40 am #28017starflixParticipant
Hello,
I’ve encountered this problem recently, that my form for some reason misses one very important field. I have no idea what can cause this bug, I tried to find what triggers this bug but had no success at all.
So my form has this input field which is hidden, when user fills dynamically created fields, all information goes into that field, which is then is processed at PHP and returned as an output. I would really appreciate any kind of help! Thank you in advance
Here are the codes:
JSfunction formString() { const pageTitles = Array.prototype.slice.call(document.querySelectorAll('.page-title'), 0).map(x => { return x.innerText; //make nodelist to array, then map over it to get names }); let finalString = ""; pageTitles.forEach(function(page) { const x = page.split(' → '); const pageClass = x[x.length -1].split(' ').join('-'); let content = document.querySelector('.' + pageClass + ' .page-content-text_textarea').value.replace(new RegExp('\r?\n','g'), '[[newline]]'); let comments = document.querySelector('.' + pageClass + ' .page-comment-text_textarea').value.replace(new RegExp('\r?\n','g'), '[[newline]]'); let title = page; if(title === "") { title = "Teksto nera"; } if(content === "") { content = "Teksto nera"; } if(comments === "") { comments = "Teksto nera"; } finalString += title + '~~~' + content + '###' + comments + ';;;'; }); console.log(finalString); document.querySelector('input[name="quform_3_164"]').value = finalString; }
PHP
add_filter('quform_get_value_html_3_164', function ($value) { $output = ''; $counter = 0; $value = explode(';;;', $value); if(count($value)) { foreach($value as $blocks) { $blocks = explode('~~~', $blocks); if(count($blocks)) { if($counter % 2 == 1) { $output .= '<div style="background-color: #f6f6f6; padding: 50px 25px;">'; $output .= '<h2 style="font-size: 32px;text-decoration: underline;">' . esc_html($blocks[0]) . '</h2>'; foreach(array_slice($blocks, 1) as $blocksChild) { $blocksChild = explode('###', $blocksChild); $blockOne = explode("[[newline]]", $blocksChild[0]); $blockTwo = explode("[[newline]]", $blocksChild[1]); if(count($blocksChild)) { $output .= '<h3>Turinys</h3>'; forEach($blockOne as $paragraph) { $output .= '<p>' . esc_html($paragraph) . '</p>'; } $output .= '<h3>Komentarai</h3>'; forEach($blockTwo as $paragraph) { $output .= '<p>' . esc_html($paragraph) . '</p>'; } } } $output .= '</div>'; } else { $output .= '<div style="background-color: #fcfcfc; padding: 50px 25px;">'; $output .= '<h2 style="font-size: 32px;text-decoration: underline;">' . esc_html($blocks[0]) . '</h2>'; foreach(array_slice($blocks, 1) as $blocksChild) { $blocksChild = explode('###', $blocksChild); $blockOne = explode("[[newline]]", $blocksChild[0]); $blockTwo = explode("[[newline]]", $blocksChild[1]); if(count($blocksChild)) { $output .= '<h3>Turinys</h3>'; forEach($blockOne as $paragraph) { $output .= '<p>' . esc_html($paragraph) . '</p>'; } $output .= '<h3>Komentarai</h3>'; forEach($blockTwo as $paragraph) { $output .= '<p>' . esc_html($paragraph) . '</p>'; } } } $output .= '</div>'; } } $counter++; } } return $output; });
December 13, 2018 at 7:54 am #28018starflixParticipantSorry If I made it not clear in original post, but field does not appear in the E-MAIL
December 17, 2018 at 1:11 pm #28030AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 18, 2018 at 1:21 pm #28039starflixParticipantHello.
I inserted this field to check what information I get. It seems its not the case in this problem. Because client just filled the form and I see he is using firefox 52 (Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0). I checked the const usability and it seems that it shouldn’t be a problem on this version. Do you can any other suggestions where problem might be laying?
Thank you in advance
December 18, 2018 at 1:58 pm #28040AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 19, 2018 at 7:48 am #28050starflixParticipantIt seems I accidentally found the problem. The problem was that the person would fill one of the fields and use some kind of symbol, for example question mark. This would ruin everything because later in the form those fields are used as classNames..
Thank you for help!
December 28, 2018 at 12:12 pm #28075AllySupport 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.