user3445165
user3445165

Reputation: 45

<input> element in tinymce

I want to have input element in my editor so user can type something in it. I've tried just write html in my textarea but the input element goes unclickable (ex1)

Value: <input type='text' value='12.3'> kg

I've also tried to make contenteditable="true" div and input worked in it without problems, so it is tinymce problem (ex2)

I can't use input in editor even if I initialize tinymce with div and set html manually

ed.getBody().innerHTML = "Value: <input type='text' value='12.3'> kg"

Upvotes: 1

Views: 2768

Answers (3)

Sufyan zaki
Sufyan zaki

Reputation: 1

You can get this effect by adding 'code' in toolbar and plugins.

tinymce.init({
  selector: 'textarea.codedemo',
  plugins: 'code',
  toolbar: 'code',
});

this adds an option 'source code' under tinymce Tools option in the toolbar menu . The source code allows you to add custom inputs Also take a look in the docs https://www.tiny.cloud/docs/enterprise/advcode/

Upvotes: 0

Afzaal Ahmad Zeeshan
Afzaal Ahmad Zeeshan

Reputation: 15860

That is because you're having the Input field inside the textarea element. Which itself is fully editable.

Take it out of the textarea, and then it would work just the way you want it to.

Upvotes: 1

Nept
Nept

Reputation: 103

You can't have an input element into textarea element.

Try

<form method="post" action="dump.php">
    <label for="kgElement">Value:</label>
    <input type='text' id="kgElement" placeholder='12.3'> kg
</form>

Upvotes: 1

Related Questions