<?= $this->extend('layouts/form.php') ?>
<?= $this->section('content') ?>

<div class="form-body">
	<h3 class="card-title">Guide Editor</h3>
	<hr>
	<?php 
	if(isset($validation)) {
	?>
		<div class='alert alert-danger alert-dismissible'>
			<?= $validation->listErrors(); ?>
			<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"> <span aria-hidden="true"></span> </button>
		</div>
	<?php
	}
	?>
	<form method='post'>
		<div class="form-group row">
			<label class="col-2 col-form-label">Title</label>
			<div class="col-10"><input class="form-control" type="text" name='guidetitle'></div>
		</div>
		<div class="form-group row">
			<label class="col-2 col-form-label">Content</label>
            <div class="col-10">
                <textarea class="form-control mb-1 editor" id="guidedetail" name="guidedetail"></textarea>
            </div>
		</div>

        <input type="hidden" name='userid_creator' value='<?= $_SESSION['userid']; ?>'>
		
		<button type="button" class="btn btn-dark float-start" onclick="window.close()">Cancel</button>
		<button type="submit" class="btn btn-success text-white float-end"> <i class="fa fa-check"></i> Submit</button>
	</form>
</div>

<?= $this->endSection() ?>

<?= $this->section('script') ?>
<script src="<?=base_url();?>/assets/tinymce/tinymce.min.js"></script>
<script>
	
	config = {
		selector:'textarea',
		height:'350',
		promotion:false,
		paste_data_images:false,
		content_style: "p { margin: 0; font-family: Verdana; }",
		plugins: 'preview importcss searchreplace autolink autosave save code visualblocks visualchars fullscreen link template codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount charmap emoticons',
		menubar: 'file edit view insert format tools table',
		toolbar: 'undo redo | bold italic underline strikethrough | fontfamily fontsize blocks | alignleft aligncenter alignright alignjustify | outdent indent |  numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | fullscreen  preview save print | template link anchor codesample',
		autosave_ask_before_unload: true,
		autosave_interval: '30s',
		automatic_uploads: false,
	};
	tinymce.init(config);
</script>
<?= $this->endSection() ?>