Skip to content

Instantly share code, notes, and snippets.

@soomtong
Last active March 2, 2022 12:14
Show Gist options
  • Save soomtong/6635053 to your computer and use it in GitHub Desktop.
Save soomtong/6635053 to your computer and use it in GitHub Desktop.
(deprecated) summernote example with php
<!-- this version of sample is too old. it's not follow recent version of summernote api -->
<!-- should check new apis and examples! sorry I am. -->
<!DOCTYPE html>
<html lang="en">
<!-- include libries(jQuery, bootstrap, fontawesome) -->
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.no-icons.min.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet">
<!-- include summernote css/js-->
<link href="build/summernote.css" / rel="stylesheet">
<script src="build/summernote.min.js"></script>
<body>
<div class="summernote container">
<div class="row">
<div class="span12">
<h2>POST DATA</h2>
<pre>
<?php print_r($_POST); ?>
</pre>
<pre>
<?php echo htmlspecialchars($_POST['content']); ?>
</pre>
</div>
</div>
<div class="row">
<form class="span12" id="postForm" action="/summernote.php" method="POST" enctype="multipart/form-data" onsubmit="return postForm()">
<fieldset>
<legend>Make Post</legend>
<p class="container">
<textarea class="input-block-level" id="summernote" name="content" rows="18">
</textarea>
</p>
</fieldset>
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" id="cancel" class="btn">Cancel</button>
</form>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#summernote').summernote({
height: "500px"
});
});
var postForm = function() {
var content = $('textarea[name="content"]').html($('#summernote').code());
}
</script>
</body>
</html>
@JohnSalazar
Copy link

@teddiey
Copy link

teddiey commented Jun 15, 2019

For some obvious reason <?php gets commented out.
But how can I bypass this.
I want to allow php tags in summernote

@maksam07
Copy link

onChange: function(contents, $editable) {
	editor.html( editor.summernote('code') );
},

@C980
Copy link

C980 commented Jul 12, 2019

Hi friends, I am not able to get html content value in textarea field when I clicked on edit button. Here I am using summernote editor.

here html code:-

<textarea name="description" id="summernote" cols="30" rows="10" value="{{x.description}}">{{x.description}}</textarea>

here script;-

<script> $('#summernote').summernote({ height: 300 }); </script>

Please help me.

my

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment