为什么 dd($request) 无法使用 Laravel 5.2 获取 TinyMCE 的请求
Why dd($request) can't get the request of TinyMCE using Laravel 5.2
我不知道是什么原因,但我有一个带有选择器的 tinymce
插件,这是我的 textarea
。我正在尝试检查我是否在文本编辑器 textarea
上收到请求。当我检查它时,我的 textarea
没有任何列,它在 +request: ParameterBag
下的 ID 为 content
截图如下。
正如您在这里看到的,它没有任何 key,这是我的文本区域的 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',
]);
}
}
尝试将名称添加到文本区域:
<div class = "form-group">
<textarea id="content" name="content"></textarea>
</div>
我不知道是什么原因,但我有一个带有选择器的 tinymce
插件,这是我的 textarea
。我正在尝试检查我是否在文本编辑器 textarea
上收到请求。当我检查它时,我的 textarea
没有任何列,它在 +request: ParameterBag
content
截图如下。
正如您在这里看到的,它没有任何 key,这是我的文本区域的 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',
]);
}
}
尝试将名称添加到文本区域:
<div class = "form-group">
<textarea id="content" name="content"></textarea>
</div>