Form misses field from time to time

Home Forums Quform WordPress Form misses field from time to time

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

    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:
    JS

    	function 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;
    });
    #28018
    starflix
    Participant

    Sorry If I made it not clear in original post, but field does not appear in the E-MAIL

    #28030
    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.

    #28039
    starflix
    Participant

    Hello.

    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

    #28040
    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.

    #28050
    starflix
    Participant

    It 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!

    #28075
    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