summaryrefslogtreecommitdiff
path: root/lib/aggiedit_web/live/post_live/form_component.html.heex
blob: aa24a3c0067cabd057b833741d14ab416556cdb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<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>