我不知道是什么原因,但我有一个tinymce
插件,其选择器是我的textarea
。我正在尝试检查我的textarea
是否是文本编辑器。当我检查时,我的textarea
没有任何列,content
+request: ParameterBag
下面的截图。
正如您在此处所看到的,它没有任何键,这是我的textarea的content
ID。任何人都可以告诉我如何解决这个问题。
脚本:
<script>
tinymce.init
({
selector: '#content',
plugins: [
'advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker',
'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
'save table contextmenu directionality emoticons template paste textcolor save'
], //The plugins configuration option allows you to enable functionality within the editor.
toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons | save',
save_enablewhendirty: true,
height: 400,
});
function get_editor_content()
{
// Get the HTML contents of the currently active editor
console.debug(tinymce.activeEditor.getContent());
// Get content of a specific editor:
var selectContent = tinymce.get('content').getContent();
}
</script>
我可以在这里得到我的textarea的价值,但仍然不知道如何在我的数据库中保存或插入它。任何帮助都会非常感激。
形式:
<form class = "form-vertical" role = "form" method = "post" action = "{{ route('document.create')}}">
<div class = "form-group">
<label for = "title" class = "control-label">Title:</label>
<input type = "text" name = "title" class = "form-control">
</div>
<div class = "form-group">
<label for = "to" class = "control-label">To:</label>
<select onChange = "showUserOptions(this)" name = "to[]" multiple class = "form-control" id = "myUserList">
@foreach ($result as $list)
<option value = "{{ $list->id }}">{{ $list->username }}</option>
@endforeach
</select>
</div>
<div class = "form-group">
<label for = "category" class = "control-label">Category:</label>
<select onChange = "showCategoryOptions(this)" name = "category" class = "form-control" id = "myCategory">
<option selected disabled>Please select role</option>
@foreach ($resultCategory as $categoryList)
<option value = "{{ $categoryList->id }}">{{ $categoryList->category_type }}</option>
@endforeach
</select>
</div>
<div class = "form-group">
<textarea id="content"></textarea>
</div>
<div class = "form-group">
<button type = "submit" class = "btn btn-primary" onclick="get_editor_content()">Send</button>
</div>
<input type = "hidden" name = "_token" value = "{{ Session::token() }}">
</form>
控制器:
class DocumentController extends Controller
{
public function getDocuments()
{
$result = DB::table('users')->where('id', '!=', Auth::id())->get();
$resultCategory = DB::table('categories')->get();
return view ('document.create')->with('result', $result)->with('resultCategory', $resultCategory);
}
public function postDocuments(Request $request)
{
dd($request);
$this->validate($request,
[
'to' => 'required',
'title' => 'required|alpha_dash|max:255',
'category' => 'required',
'content' => 'required',
]);
}
}
答案 0 :(得分:0)
尝试为textarea添加名称:
<div class = "form-group">
<textarea id="content" name="content"></textarea>
</div>