Reputation:
My problem:
Everything is appearing within the view as expected, but once the user has edited the text field, I want to then re-upload it to the database. However, within the Controller, I cannot get
the text within the 'textarea'.
Current HTML set up within my view is:
{!! Form::open(array('route' =>
array('updateReport', $report->first()->id), 'role'=>'form','id'=>'updateReport')) !!}
<textarea class="form-control" id="report" name="report" rows="15">
{{ $report->first()->html }}</textarea>
<button type="submit" class="btn btn-labeled btn-success" aria-hidden="true">
<span class="btn-label">
<i class="glyphicon glyphicon-save"></i></span> Update Report</button>
{!! Form::close() !!}
Javascript section to initialise the TinyMCE:
<script type="text/javascript">
tinymce.init({
selector: '#report',
menubar: false,
browser_spellcheck: true,
});
</script>
I have tried:
Input::all() and Input::get('report')
- both return null
.
How can I get the raw HTML that's newly edited and stored "behind the scenes", surely there must be a simple way?
Many thanks in advance.
Upvotes: 0
Views: 3313
Reputation: 8583
You can use the setup
call back to bind a change
event to the editor which will trigger a save. This places the modified content back in the original textarea
allowing you to post it to your script.
<script type="text/javascript">
tinymce.init({
selector: '#report',
setup: function (editor) {
editor.on('change', function () {
tinymce.triggerSave();
});
},
menubar: false,
browser_spellcheck: true
});
</script>
Upvotes: 1
Reputation: 3358
If there's only one field to worry about, tinymce.activeEditor.getContent()
should do the trick
Upvotes: 0