Closed vladkucherov closed 9 years ago
Try only with the textarea
field type by replacing type => 'ace'
to type => 'textarea
and see if the problem that the widget form data are not saved persists. If the data stat getting saved, it is likely an issue of the ACE field type which is not compatible with widget forms.
@michaeluno Yes, you are right. I tried the textarea
and it worked. Any ideas on why this is happening?
By glancing at the code, it could be unescaped characters.
This part
. "<textarea " . $this->generateAttributes( $aInputAttributes ) . " >"
. $aField['value']
. "</textarea>"
May have to be
. "<textarea " . $this->generateAttributes( $aInputAttributes ) . " >"
. esc_textarea( $aField['value'] )
. "</textarea>"
Doesn't seem to help.
Note that after I save, the editor is changed to a textarea, maybe that's the problem?
Sounds like the field type does not renew the event binding of the editor script after the form is saved. In that case, it's not compatible with widget forms. You should ask Per to support it.
@michaeluno I fixed this issue by binding the addAceEditor
to widget-updated
event.
jQuery(document).on('widget-updated', function(e, widget){
jQuery('textarea[data-ace_language]').each(function () {
addAceEditor(jQuery(this));
});
});
But the data is still not stored. I looked at the headers, and for some reason it sends the original content, not the latest one I just edited.
@michaeluno You can participate if you wish. https://github.com/soderlind/AceCustomFieldType/pull/1
Thank you, I've merged soderlind/AceCustomFieldType#1
I think we'll move this issue to here https://github.com/soderlind/AceCustomFieldType/issues/2
https://github.com/soderlind/AceCustomFieldType/pull/3
Fixed that :smile:
Glad to hear you sorted it out!
Hi,
I found that the widgets are not saved properly. I tried to edit a widget that has a textarea / Ace Editor, after I tried to save the changes, the widget returned to it's previous state with previous content. only after that it saved my changes.
In the case of Ace Editor - I save the content, it's not saved and the editor disappears without any JS error. After it turned to a textarea - it will save.
Ideas?