• Resolved jollock

    (@jollock)


    Hi there,

    i’m trying to use two textarea elements with placeholders in the custom html field within my choices.
    Every time i save the page, all placeholder disappear.

    I also tried to put them in with jquery, but that didnt work either.

    So my questions are:

    1. Is there any possibility of getting placeholders work within the custom html?
    2. Is there any way to give all choices buttons ids?

    Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Marc Lacroix

    (@marcusig)

    Hi there,

    1. Is there any possibility of getting placeholders work within the custom html?

    Could you send an example of the html you put in the custom html field?

    2. Is there any way to give all choices buttons ids?

    You could probably do that by using one of the JavaScript hooks in the configurator, though you can add CSS classes to each choice, making it possible to target anything you want using CSS or JavaScript.

    Best,
    Marc

    Thread Starter jollock

    (@jollock)

    Hi Marc,

    thank you for your quick reply!!!

    My HTML code looks like this:

    <textarea id='heading' class='heading'></textarea>
    <textarea id='bodytext' class='bodytext'></textarea>

    As soon as i put my placeholder into it like placeholder="Please enter..." and save everything, its gone when i reopen the product configurator.

    I’m gona check the JavaScript hooks today!

    Thaaanks

    Plugin Contributor Marc Lacroix

    (@marcusig)

    So I believe what’s happening is that it’s being stripped when sanitizing the content.

    You can try using this filter, which should prevent stripping the placeholder:

    add_filter( 'mkl_pc/custom_html/allowed_tags', function( $tt ) {
    	if ( isset( $tt[ 'textarea' ] ) ) {
    		$tt[ 'textarea' ]['placeholder'] = [];
    	}
    	return $tt;
    } );

    If you need to enable more html, you can look at wp_kses_allowed_html, and wp_kses, which are the 2 methods used to sanitize that field.

    Marc

    Thread Starter jollock

    (@jollock)

    Yeah man, thank you so much!

    That filter fixed my issue!

    Have a nice day!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom HTML in Content Layers Choice removes placeholders’ is closed to new replies.