<?php Block::put('breadcrumb') ?>
    <ul>
        <li><a href="<?= Backend::url('dynamedia/posts/posts') ?>">
                <?= e(trans('dynamedia.posts::lang.common.labels.posts'))?>
            </a></li>
        <li>
            <?= e(trans('dynamedia.posts::lang.common.titles.editing', ['name' => $this->formGetModel()->title]))?>
            <a target="_blank" style="color:blue;" href="<?= $this->formGetModel()->url ?>">
                (<?= e(trans('dynamedia.posts::lang.common.labels.live_view'))?>)
            </a>
        </li>
    </ul>
<?php Block::endPut() ?>

<?php if (!$this->fatalError): ?>
        <?= Form::open(['class' => 'layout']) ?>

            <?php if (Dynamedia\Posts\Classes\Acl\AccessControl::userCanEditPost($this->widget->form->model, $this->user)): ?>
                <div class="layout-row">
                    <?= $this->formRender(); ?>
                </div>

                <div class="form-buttons">
                    <div class="loading-indicator-container">
                        <button
                            type="submit"
                            data-request="onSave"
                            data-request-data="redirect:0"
                            data-hotkey="ctrl+s, cmd+s"
                            data-load-indicator="<?= e(trans('backend::lang.form.saving_name', ['name'=>$formRecordName])) ?>"
                            class="btn btn-primary">
                            <?= e(trans('backend::lang.form.save')) ?>
                        </button>
                        <button
                            type="button"
                            data-request="onSave"
                            data-request-data="close:1"
                            data-hotkey="ctrl+enter, cmd+enter"
                            data-load-indicator="<?= e(trans('backend::lang.form.saving_name', ['name'=>$formRecordName])) ?>"
                            class="btn btn-default">
                            <?= e(trans('backend::lang.form.save_and_close')) ?>
                        </button>
                        <button
                            type="button"
                            class="oc-icon-trash-o btn-icon danger pull-right"
                            data-request="onDelete"
                            data-load-indicator="<?= e(trans('backend::lang.form.deleting')) ?>"
                            data-request-confirm="<?= e(trans('backend::lang.form.confirm_delete')) ?>">
                        </button>
                        <span class="btn-text">
                            or <a href="<?= Backend::url('dynamedia/posts/posts') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
                        </span>
                    </div>
                </div>

            <?php else: ?>
                <div class="layout-row">
                    <?= $this->formRenderPreview() ?>
                </div>

                <div class="form-buttons">
                    <div class="loading-indicator-container">
                        <span class="btn-text">
                            <a href="<?= Backend::url('dynamedia/posts/posts') ?>"><?= e(trans('backend::lang.form.cancel')) ?></a>
                        </span>
                    </div>
                </div>
            <?php endif ?>

        <?= Form::close() ?>

<?php else: ?>

    <p class="flash-message static error"><?= e($this->fatalError) ?></p>
    <p><a href="<?= Backend::url('dynamedia/posts/posts') ?>" class="btn btn-default"><?= e(trans('backend::lang.form.return_to_list')) ?></a></p>

<?php endif ?>
