Skip to content

Commit

Permalink
Use full URL for form submit path + pretty print form HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
wmnnd committed Feb 21, 2022
1 parent d412816 commit f10229e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/keila_web/live/form_edit_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ defmodule KeilaWeb.FormEditLive do
mode: :embed,
changeset: Ecto.Changeset.change(%Keila.Contacts.Contact{})
})
|> Phoenix.HTML.Safe.to_iodata()
|> Floki.parse_fragment!()
|> Floki.raw_html(pretty: true)

socket
|> assign(:form_preview, form_preview)
Expand Down
2 changes: 1 addition & 1 deletion lib/keila_web/templates/form/edit_live.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
<%= if @form_preview.settings.csrf_disabled do %>
<h2 class="mt-4">Form HTML</h2>
<div class="flex items-start gap-4">
<textarea class="w-full bg-gray-800" rows="2" x-ref="form-html"><%= @embed %></textarea>
<textarea class="w-full bg-gray-800 text-sm" rows="5" x-ref="form-html"><%= @embed %></textarea>
<button class="button" @click.prevent="$refs['form-html'].select(); document.execCommand('copy'); showClipboardMessage = true; setTimeout(() => showClipboardMessage = false, 1000)">
<%= gettext("Copy") %>
</button>
Expand Down
2 changes: 1 addition & 1 deletion lib/keila_web/views/form_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule KeilaWeb.FormView do

form_for(
changeset,
Routes.form_path(KeilaWeb.Endpoint, :submit, form.id),
Routes.form_url(KeilaWeb.Endpoint, :submit, form.id),
[class: @form_classes, style: form_styles, csrf_token: csrf_enabled?],
fn f ->
[
Expand Down

0 comments on commit f10229e

Please sign in to comment.