I have created one form in template file using HTML Tags like input, select, buttons etc. I have added textarea
in form for address and i want to change it to wysiwyg editor
.
- Shall i use js/css provided by magento itself?
- How to achieve this (change
textarea
towysiwyg editor
) quickly?
P.S. : I want to do this in template html
file only. There is no form.php, grid.php etc.
I went through couple of other question/answers here on stackoverflow/magentostack regarding bringing backend tinyMCE to frontend,
Through these
https://magento.stackexchange.com/questions/49504/how-to-add-wysiwyg-editor-to-custom-frontend-form-of-custom-module-in-magento1-9
Magento add wysiwyg to custom frontend form
But they got issue listed/commented with
Uncaught ReferenceError: tinyMCE is not defined error
. They might have worked on certain pages(if any), but when i tried on product detail page, it didn't work and showed me same error on consoletinyMCE is not defined
.So, i went to see which file/js is responsible for this. and i figured it out that
js/tiny_mce/tiny_mce_jquery.js
is the one responsible for tinyMCE.So you need to include this file, where you want wysiwyg editor. like i was testing on product detail page so i added only on it
Then on product view page(for.eg. was just to test) where i added text field
<textarea id="myfield"></textarea>
And script part, reference from those listed question above
And it worked,
Ideal solution would be using Magento's FORM concept to be able to achieve this.
However, since custom template is being used, I guess here is what you need.
1) Put this code in the .phtml file you want the editor to appear directly.
2) In the 6th line of the code you can see elements: "short_description". You can change "short_description" with the element id you want. You can add more than one element id separated with comma and without spaces.
You might be looking for this.
Let me know if this works for you and I was able to understand this correctly.
Happy to Help!
Happy Coding...