2016-08-20 14 views
2

私はLaravel 5.2を使用していて、UniSharp/laravel-ckeditorパッケージを使用してプロジェクトにckeditorを実装しています。すべて正常に動作するようです。しかし、ckeditor入力フィールドのデータを送信すると、他の入力フィールドのデータが正常に動作しています.ckeditorの代わりに通常のテキスト領域を使用すると、正常に動作しています。私の見解ではLaravel ckeditorデータがデータベースに挿入されない

フォーム:

{{Form::open(array('url'=>'gettopics'))}} 
      <input type="text" name="title" class="form-control"/> 
      **<input type="textarea" name="detail" id="article-ckeditor">** 
    {{Form::close()}} 



<script> 
     CKEDITOR.replace('article-ckeditor'); 

    </script> 

ルート:

Route::post('gettopics','[email protected]'); 

コントローラー:

public function gettopics(Request $request){ 
    $topic=new Topic; 
$topic->title=$request->Input('title'); 
$topic->detail=$request->Input('detail'); 
$topic->save(); 
} 

答えて

0

テキストエリアのHTMLタグが誤って挿入されます。コードを次のように変更する必要があります。

My Editor:<br> 
      <textarea name="article-ckeditor" id="article-ckeditor">&lt;p&gt;Initial editor content.&lt;/p&gt;</textarea> 
      <script> 
       CKEDITOR.replace('article-ckeditor'); 
      </script> 

また、コントローラには入力と呼ばれる機能がありません。あなたのコントローラーを次のように変更してください:

public function gettopics(Request $request){ 
    $topic=new Topic; 
    $topic->title=$request->input('title'); 
    $topic->detail=$request->input('detail'); 
    $topic->save(); 
} 
+0

これはうまくいきます。ありがとうございます。しかし、私のページにデータを表示するにはどうすればいいですか?正常な手順は機能していません。 –

+0

通常の手順ではどういう意味ですか? '{{$ topic-> detail}}'? –

+0

はい。{{$ topic-> detail}}を使用すると、それは変です。

私は自分自身のために考える時間を必要とする家族に語った。ビューはここでは素晴らしいですが、しばらくしてからそれを何度も見たことがあります。しばらくすると、臨時の人は「余分」を失う。

関連する問題