<?php

/**
 * @var $csrf_token
 * @var \Johncms\Modules\Guestbook\Domain\Models\GuestbookEntry $message
 * @var string $postText
 * @var string $text
 * @var $errors
 */

$this->layout('system::layout/default'); ?>

<h4><?= __('Reply') ?></h4>
<?php if (! empty($errors['csrf_token'])): ?>
    <div class="alert alert-danger"><?= implode(', ', $errors['csrf_token']) ?></div>
<?php endif ?>
<form action="/guestbook/otvet?id=<?= $id ?>" method="post">
    <input type="hidden" name="csrf_token" value="<?= $csrf_token ?>"/>
    <p>
        <b><?= __('Author') ?>:</b> <?= $message->name ?> <br>
        <?= $postText ?>
    <p>
        <?= $this->fetch(
            'guestbook::ckeditor',
            [
                'label'  => __('Reply'),
                'errors' => implode(', ', $errors['message'] ?? []),
                'value'  => $this->e($text),
            ]
        ) ?>
    <div>
        <button type="submit" name="submit" value="submit" class="btn btn-primary me-2"><?= __('Save') ?></button>
        <a href="/guestbook/" class="btn btn-outline-primary"><?= __('Back') ?></a>
    </div>
</form>
<?php $this->push('scripts') ?>
<?= $this->fetch('guestbook::ckeditor') ?>
<?php $this->stop(); ?>
