<section class="content-header">
    <h1><?= __('Add new post') ?></h1>

    <div class="actions">
        <a data-ajax class="btn btn-default btn-sm" href="<?= admin_url_to('/posts') ?>"><?= __('List') ?></a>
    </div>
</section>

<section class="content">
    <div class="box box-default">
        <form data-upload data-ajax class="form-focus" action="<?= admin_url_to('/posts/add') ?>" method="post">
            <?= csrf_field() ?>

            <div class="box-body">
                <div class="section">
                    <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
                            <h5><?= __('Post') ?></h5>
                        </div>

                        <div class="col-lg-9 col-md-9 col-sm-8 col-xs-12">
                            <div class="row">
                                <div class="col-md-8">
                                    <div class="form-group">
                                        <label class="control-label" for="title"><?= __('Title') ?> <span class="required">*</span></label>
                                        <input class="form-control" type="text" name="title" id="title" />
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="locale"><?= __('Locale') ?></label>
                                        <select class="form-control" name="locale" id="locale">
                                            <option value=""></option>
                                            <?php foreach (app()->getLanguages() as $locale => $name): ?>
                                                <option<?= $locale === config('locale', 'pt_BR') ? ' selected' : '' ?> value="<?= $locale ?>"><?= $name ?></option>
                                            <?php endforeach ?>
                                        </select>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label" for="link">URL</label>
                                <input class="form-control" type="text" name="link" id="link" />
                            </div>

                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="type"><?= __('Category') ?> <span class="required">*</span></label>
                                        <select class="form-control" name="type" id="type">
                                            <option value=""></option>
                                            <?php foreach (config('posts.types', []) as $id => $type): ?>
                                                <option value="<?= $id ?>"><?= $type['name'] ?></option>
                                            <?php endforeach ?>
                                        </select>
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="product-image"><?= __('Image cover') ?></label>
                                        <input data-upload-field class="form-control" type="file" name="image_cover" />
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="config-allow-comments"><?= __('Allow comments') ?>?</label>
                                        <div >
                                            <input<?= config('posts.allow_comments') ? ' checked' : ' disabled' ?> class="form-control toggle" type="checkbox" id="config-allow-comments" value="1" name="allow_comments" />
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label" for="body"><?= __('Post') ?> <span class="required">*</span></label>
                                <textarea class="form-control editor" name="body" id="body"></textarea>
                            </div>

                            <div class="form-group">
                                <label class="control-label" for="description"><?= __('Description') ?></label>
                                <textarea class="form-control" name="description" id="description"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="box-footer">
                <div class="row">
                    <div class="col-sm-offset-3" style="padding-left:15px">
                        <input type="submit" class="btn btn-primary" value="<?= __('Save') ?>" />
                    </div>
                </div>
            </div>
        </form>
    </div>
</section>