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

<?= $this->section('content') ?>
<?php
$bugcommentid = '';
$bugid = '';
$bugcommenttext = '';
$userid = '';
foreach($bugcomment as $data) {
    $bugcommentid = $data['bugcommentid'];
    $bugid = $data['bugid'];
    $bugcommenttext = $data['bugcommenttext'];
    $userid = $data['userid'];
}

?>
<div class="form-body">
	<h3 class="card-title">Comment 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'>
        <input type="hidden" name='bugcommentid' value='<?= $bugcommentid; ?>'>
        <input type="hidden" name='bugid' value='<?= $bugid; ?>'>
        <input type="hidden" name='userid' value='<?= $userid; ?>'>
		<div class="form-group row">
			<label class="col-2 col-form-label">Comment</label>
            <div class="col-10">
                <textarea class="form-control mb-1 editor" id="commenttextarea" name="bugcommenttext"><?=$bugcommenttext; ?></textarea>
            </div>
		</div>
		<a type="button" class="btn btn-dark float-start" href="/bugs/view/<?= $bugid; ?>">Cancel</a>
		<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:'#commenttextarea',
        promotion:false,
        menubar:false,
        forced_root_block : 'pre',
		plugins: 'lists',
		// plugins: 'emoticons',
		// relative_urls: true,
		toolbar: 'insertfile undo redo styles styleselect | bold italic | forecolor backcolor emoticons | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
    };
    tinymce.init(config);
</script>
<?= $this->endSection() ?>