<?php

/**
 * This file is part of JohnCMS Content Management System.
 *
 * @copyright JohnCMS Community
 * @license   https://opensource.org/licenses/GPL-3.0 GPL-3.0
 * @link      https://johncms.com JohnCMS Project
 */

/**
 * @var $title
 * @var $page_title
 * @var $csrf_token
 * @var $form_data
 * @var \Johncms\Modules\Forum\Domain\Models\ForumTopic $topic
 * @var $back_url
 */

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

<form name="rename_topic" action="/forum/change-topic/<?= $topic->id ?>/" method="post">
    <input type="hidden" name="csrf_token" value="<?= $csrf_token ?>"/>
    <?php if (! empty($errors['csrf_token'])): ?>
        <div class="alert alert-danger"><?= implode(', ', $errors['csrf_token']) ?></div>
    <?php endif ?>
    <div class="form-group">
        <label for="name"><?= __('Topic name') ?></label>
        <input type="text" class="form-control <?= ! empty($errors['name']) ? 'is-invalid' : '' ?>" id="name" placeholder="<?= __('Topic name') ?>"
               name="name" value="<?= $this->e($form_data['name']) ?>" required>
        <?php if (! empty($errors['name'])): ?>
            <div class="invalid-feedback d-block"><?= implode(', ', $errors['name']) ?></div>
        <?php endif ?>
    </div>
    <div class="form-group">
        <label for="meta_keywords"><?= __('Meta keywords') ?></label>
        <textarea name="meta_keywords" class="form-control <?= ! empty($errors['meta_keywords']) ? 'is-invalid' : '' ?>" id="meta_keywords" rows="1"><?= $this->e($form_data['meta_keywords']) ?></textarea>
        <?php if (! empty($errors['meta_keywords'])): ?>
            <div class="invalid-feedback d-block"><?= implode(', ', $errors['meta_keywords']) ?></div>
        <?php endif ?>
    </div>
    <div class="form-group">
        <label for="meta_description"><?= __('Meta description') ?></label>
        <textarea name="meta_description" class="form-control <?= ! empty($errors['meta_description']) ? 'is-invalid' : '' ?>" id="meta_description" rows="1"><?= $this->e($form_data['meta_description']) ?></textarea>
        <?php if (! empty($errors['meta_description'])): ?>
            <div class="invalid-feedback d-block"><?= implode(', ', $errors['meta_description']) ?></div>
        <?php endif ?>
    </div>
    <div>
        <button type="submit" name="submit" value="1" class="btn btn-primary"><?= __('Save') ?></button>
        <a href="<?= $back_url ?>" class="btn btn-secondary"><?= __('Back to topic') ?></a>
    </div>
</form>
