<?php $this->layout(
    'system::layout/default',
    [
        'title'      => __('Add news'),
        'page_title' => __('Add news'),
    ]
) ?>

<h4><?= __('Add news') ?></h4>
<form action="/news/add/" method="post">
    <div class="form-group">
        <label for="title"><?= __('Title') ?></label>
        <input type="text"
               class="form-control"
               maxlength="255"
               name="name"
               id="title"
               required
               value=""
               placeholder="<?= __('Title') ?>"
        >
    </div>
    <div class="form-group">
        <label for="text"><?= __('Text') ?></label>
        <textarea id="text" class="form-control" name="text" rows="<?= $user->config->fieldHeight ?>"></textarea>
    </div>
    <?php if (! empty($discussions)): ?>
        <div class="form-group">
            <label for="discussion"><?= __('Discussion') ?></label>
            <select size="5" name="rz" class="form-control" id="discussion">
                <option value="0" selected><?= __('Do not discuss') ?></option>
                <?php foreach ($discussions as $forum): ?>
                    <optgroup label="<?= $forum['name'] ?>">
                        <?php foreach ($forum['sections'] as $subsection): ?>
                            <option value="<?= $subsection['id'] ?>"><?= $subsection['name'] ?></option>
                        <?php endforeach; ?>
                    </optgroup>
                <?php endforeach; ?>
            </select>
        </div>
    <?php endif; ?>
    <div>
        <button type="submit" class="btn btn-primary"><?= __('Save') ?></button>
        <a href="/news/" class="btn btn-outline-primary ml-2"><?= __('Back to news') ?></a>
    </div>
</form>
