<?php

/**
 * @var Mobicms\Render\Template\Template $this
 * @var int|null $parent_id
 * @var string $parent_section_name
 * @var string $form_action
 * @var string $back_url
 * @var int $field_height
 * @var string|null $error_message
 * @var string $csrf_token
 */

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

<?php if (! empty($error_message)): ?>
    <div class="alert alert-danger shadow border-0"><?= $error_message ?></div>
<?php endif; ?>
<form action="<?= $this->e($form_action) ?>" method="post">
    <input type="hidden" name="csrf_token" value="<?= $csrf_token ?>">
    <?php if (! empty($parent_id)): ?>
        <h3><?= __('Parent section:') ?> <?= $this->e($parent_section_name) ?></h3>
    <?php endif; ?>
    <div class="form-group">
        <label for="name"><?= __('Title') ?></label>
        <input type="text" name="name" class="form-control" id="name" placeholder="<?= __('Title') ?>" required>
        <div class="text-muted small"><?= __('Min. 2, Max. 30 characters') ?></div>
    </div>

    <div class="form-group">
        <label for="desc"><?= __('Description') ?></label>
        <textarea class="form-control" rows="<?= $field_height ?>" name="desc" id="desc"></textarea>
        <div class="small text-muted"><?= __('Optional field') ?><br><?= __('Min. 2, Max. 500 characters') ?></div>
    </div>

    <?php if (! empty($parent_id)): ?>
        <h3><?= __('Common access') ?></h3>
        <div class="form-check">
            <input type="radio" id="allow0" name="allow" value="0" class="form-check-input" checked="checked">
            <label class="form-check-label" for="allow0"><?= __('Common access') ?></label>
        </div>
        <div class="form-check">
            <input type="radio" id="allow1" name="allow" value="1" class="form-check-input">
            <label class="form-check-label" for="allow1"><?= __('Assign the newly created authors as curators') ?></label>
        </div>
        <div class="form-check">
            <input type="radio" id="allow2" name="allow" value="2" class="form-check-input">
            <label class="form-check-label" for="allow2"><?= __('Allow authors to edit the 1st post') ?></label>
        </div>
        <div class="form-check">
            <input type="radio" id="allow4" name="allow" value="4" class="form-check-input">
            <label class="form-check-label" for="allow4"><?= __('Only for reading') ?></label>
        </div>
    <?php endif; ?>

    <h3 class="mt-3"><?= __('Section type') ?></h3>
    <div class="form-check">
        <input type="radio" id="section_type1" name="section_type" value="0" class="form-check-input" checked="checked">
        <label class="form-check-label" for="section_type1"><?= __('For subsections') ?></label>
    </div>
    <div class="form-check">
        <input type="radio" id="section_type2" name="section_type" value="1" class="form-check-input">
        <label class="form-check-label" for="section_type2"><?= __('For topics') ?></label>
    </div>

    <div class="mt-3">
        <input type="submit" value="<?= __('Add') ?>" class="btn btn-primary">
        <a href="<?= $this->e($back_url) ?>" class="btn btn-secondary"><?= __('Cancel') ?></a>
    </div>
</form>
