Search code examples
javascriptjquerylaravellaravel-5summernote

Text not storing from summernote in Laravel


I want to integrate summernote (summernote.org) in a textarea and save in database.

my view code:

<div class="col-lg-3"><label>Estado</label>
<textarea name="textfield4" id="textfield4"></textarea></div>
 <button type="submit" class="btn btn-success">Save</button>
<input type="hidden" value="{{Session::token()}}" name="_token">

my js code:

              <script>
           $('#textfield4').summernote({

            height:200
           });
             </script>

Solution

  • Please write me what is the error message if its not working, I have modified your javascript code, replace the yourformid with actual form id and try, I assume you have a form with action defined in the html,

    $(function(){
    
    $('#estado').summernote(
    {
    
      toolbar: [
                    ['headline', ['style']],
                    ['style', ['bold', 'italic', 'underline', 'superscript', 'subscript', 'strikethrough', 'clear']],
                    ['textsize', ['fontsize']],
                    ['alignment', ['ul', 'ol', 'paragraph', 'lineheight']],
                ],
    
    height:120
    });
    
    $("#yourformid").submit(function(e) {
         var self = this;
         e.preventDefault();
    
         var estado = $('#estado').code();
         $("#textfield4").html(estado); //populate text area
         self.submit();
         return false; 
    });
    });
    

    make sure your token being passed or use the following method to generate token,

    <input type="hidden" name="_token" value="{{ csrf_token()