<div>
  <h2><%= @title %></h2>

  <.form
    let={f}
    for={@changeset}
    id="post-form"
    phx-target={@myself}
    phx-change="validate"
    phx-submit="save">
  
    <div class="form-group">
      <%= label f, :title %>
      <%= text_input f, :title, class: "form-control" %>
      <%= error_tag f, :title %>
    </div>
  
    <div class="form-group mt-2">
      <%= label f, :body %>
      <%= textarea f, :body, class: "form-control" %>
      <%= error_tag f, :body %>
    </div>

    <div class="form-group mt-2">
      <%= if !Ecto.assoc_loaded?(@post.upload) do %>
        <%= live_file_input @uploads.upload %>
        <%= for upload <- @uploads.upload.entries do %>
          <div class="row">
            <div class="column">
              <%= live_img_preview upload, height: 80 %>
            </div>
          </div>
        <% end %>
      <% end %>
    </div>
  
    <div class="mt-2">
      <%= submit "Save", phx_disable_with: "Saving...", class: "btn btn-primary" %>
    </div>
  </.form>
</div>