• I’ve researched all day on how to achieve this and I finally made it.

    2 changes are required:

    * contact-form-7/modules/quiz.php after lines 59 add

    if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
    	$atts['placeholder'] = $question;
    	$question = '';
    }

    * contact-form-7/includes/js/scripts.js change wpcf7RefillQuiz function to

    $.fn.wpcf7RefillQuiz = function(quiz) {
    	return this.each(function() {
    		var form = $(this);
    
    		$.each(quiz, function(i, n) {
    			form.find(':input[name="' + i + '"]').clearFields();
    			if ( form.find(':input[name="' + i + '"]').attr('placeholder') ) {
    				form.find(':input[name="' + i + '"]').siblings('span.wpcf7-quiz-label').remove();
    				form.find(':input[name="' + i + '"]').attr('placeholder',n[0]);
    			} else {
    				form.find(':input[name="' + i + '"]').siblings('span.wpcf7-quiz-label').text( n[0] );
    			}
    	form.find('input:hidden[name="_wpcf7_quiz_answer_' + i + '"]').attr('value', n[1]);
    		});
    	});
    };

    Please include this into the next update, I don’t know how to hook my own function into the form submission scripting 😐

    https://wordpress.org/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Please add placeholder support for [quiz], CODE HERE’ is closed to new replies.