I thought it would be trivial to create a rich text field type for use with contour forms:
I just took the code for the textarea field type.
I added some references to the tinyMCE js in the view for my custom field type to actually replace a text area with the rich text editor.
The form displays fine but data is not submitted.
I guess this is because TinMCE replaces the text area (which is rendered invisible) with an iframe that has the same id as the original text area but with "_ifr" stuck at the end of it.
Even if I change the code for my custom field type:
public override List<object> ProcessValue(HttpContextBase httpContext)
{
List<object> objs = new List<object>();
HttpRequestBase request = httpContext.Request;
Guid id = this.AssociatedField.Id;
string item = request[string.Concat(id.ToString(), "_ifr")] ?? "";
objs.Add(item);
return objs;
}
I appreciate the feedback but I have made custom fieldtypes before so I know how to do it for simple cases.
In this particular case, I can get my field type to display the TinyMCE just fine.
The problem lies with the way Contour seems to retrieve the data from a field: The data seem to be taken from the texture with a specific id.
However, when TinyMCE is applied to a textarea, the original texture is just hidden and a bunch of new elements are generated to show the WYSIWYG editor. Data then entered by the user will end up in an iFrame with a modified id from the id of the original text area (original id is appended with _ifr)
Hoewever, when trying to modify the code behind of my FieldType to try and get the data entered from this new id, it does not work for some reason...
Contour Rich Text FieldType
Hi guys,
A rather urgent question I'm afraid.
I thought it would be trivial to create a rich text field type for use with contour forms:
The form displays fine but data is not submitted.
I guess this is because TinMCE replaces the text area (which is rendered invisible) with an iframe that has the same id as the original text area but with "_ifr" stuck at the end of it.
Even if I change the code for my custom field type:
It does not work.
The view:
The iframe generated by tinyCE
Anybody have an idea on how to get it working?
Hi Kris,
Perhaps this post can help you further with creating your custom field type using the rich text editor.
http://our.umbraco.org/forum/umbraco-pro/contour/38385-Custom-Field-Type-in-V3
Hope this helps,
/Dennis
Hi Dennis,
I appreciate the feedback but I have made custom fieldtypes before so I know how to do it for simple cases.
In this particular case, I can get my field type to display the TinyMCE just fine.
The problem lies with the way Contour seems to retrieve the data from a field: The data seem to be taken from the texture with a specific id.
However, when TinyMCE is applied to a textarea, the original texture is just hidden and a bunch of new elements are generated to show the WYSIWYG editor. Data then entered by the user will end up in an iFrame with a modified id from the id of the original text area (original id is appended with _ifr)
Hoewever, when trying to modify the code behind of my FieldType to try and get the data entered from this new id, it does not work for some reason...
That is why I posted all this code...
Comment author was deleted
Have a look at this stackoverflow thread, http://stackoverflow.com/questions/5807156/tinymce-not-sending-value so try adding a call to tinyMCE.triggerSave() on form submit
Hi Tim,
Thanks for the tip.
I actually already tried
And the value of the text area is indeed kept up to date with this but for some reason, upon submit, the data is not stored by contour.
In contrast, if I use any of the markdown editors available left and right, e.g. http://toopay.github.io/bootstrap-markdown/
It does work. However, in the case of those editors, it seems the actual innerhtml of the texture element gets updated.
So maybe, I'll give that a try... I would still love to use TinyMCE though.
Comment author was deleted
Maybe this one can help http://stackoverflow.com/questions/11035657/not-getting-post-value-of-textarea-when-using-tinymce since the triggersave seems to be for when you are ajax submitting the form
$('#elm1').html(tinymce.get('elm1').getContent());
Also tried that now but it does not work.
However, I am starting to think that there is some escaping or something going on.
If I remove all editors from my textarea and try to submit:
The form does not go through apparently...
is working on a reply...