@using Library.Models;
@{
    string title = ViewBag.Title;
    string caption = ViewBag.Caption;
    string AuthorsError = ViewBag?.AuthorsError;
    BookModel book = ViewBag?.Book ?? null;
    IEnumerable<AuthorModel> authors = ViewBag?.Authors;
}

<form id="AddAuthor" style="align-self:center;" method="post">
    <div class="fields h-12">
        <h2>@caption</h2>
        <div class="fields__item">
            <div class="w-30 text-right">
                <label class="padding-right-10" for="Authors" runat="server" Text="">Автор</label>
            </div>
            <div class="w-70">
                <select @((AuthorsError != null) ? "class=error" : "") name="Authors" id="Authors" )>
                    <option hidden value=""></option>
                    @foreach (AuthorModel a in authors)
                    {
                        <option value="@a.Name">@a.Name</option>
                    }
                </select>
            </div>
        </div>
        @if (AuthorsError != null)
        {
        <div class="text-error">@AuthorsError</div>
        }
        <button type="submit">Добавить</button>
    </div>
</form>
